#1 2023-05-30 03:32:53

keinn
Member
Registered: 2014-10-20
Posts: 100

may be bug :TRestHttpServer not working in dll

to provide full rest http server all works fine until you do it in a dll.
it will cause app to hang(NO RESPONSE) problems.

after days of debug , i found that :
problem 1:
  when use any of  HTTP_API_MODES (httpsys) to create the server ,if you have no Admin rights , it will dead at line 856 FreeAndNil(fHttpServer);
  what we expected is to fallback to normal socket-based server, but the failed fHttpServer seems can not be destroyed .
  THttpServerGeneric.Destroy call ShutdownThread,but it can not break the loop.


problem 2:
  useHttpSocket mode always cause THttpServerSocketGeneric.WaitStarted raise 'WaitStarted timeout after' exception.

Offline

#2 2023-08-30 01:08:41

keinn
Member
Registered: 2014-10-20
Posts: 100

Re: may be bug :TRestHttpServer not working in dll

newly found: that's because thread in dll not work the same as in exe , thread execute process only start work 'AFTER' DLL_Process_Attach.
so ,we should NOT wait somethine depend on execute process result ,

like THttpServerSocketGeneric(fHttpServer).WaitStarted({sec=}30, TLS),
it's GetExecuteState depends on thread execute setting fExecuteState state.

delete waitstarted then we works fine in dll.

is there another way to workaround this ? delete waitstarted process seems not good idea.

(all *httpserver have the same issue)

Offline

#3 2023-08-30 06:58:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,134
Website

Re: may be bug :TRestHttpServer not working in dll

Thanks a lot for the feedback and investigation.

You can register the http.sys URI with Admin rights, then execute the program (and its dll) with normal user rights.

Couldn't you just run the http server class instances after DLL_PROCESS_ATTACH ?

Offline

Board footer

Powered by FluxBB