apustotin
(Alexander Pustotin)
March 10, 2021, 9:08am
1
Hello
You can reproduce the bug with the following code:
oServer := TROHttpServerApiServer.Create();
oServer.ThreadCnt := 2; // any <> 1
oServer.Active := True;
...
The reason is that worker threads created in UpdateThreads()
begin their execution before activating the server, where fReqQueueHandle
is initialized.
It leads to ERROR_INVALID_HANDLE
in HttpServerAPI.ReceiveHttpRequest
and escaping from TROHttpThread.IntExecute
.
Best regards
Alexander
EvgenyK
(Evgeny Karpov)
March 10, 2021, 10:18am
2
Hi,
weird, but this code
works w/o any errors.
what I miss?
apustotin
(Alexander Pustotin)
March 10, 2021, 12:30pm
3
Hi Evgeny,
works w/o any errors.
what I miss?
the code I proposed doesn’t raise any evident error but it doesn’t mean that all is right.
Currently, TROHttpThread.IntExecute executes just ONCE, because HttpServerAPI.ReceiveHttpRequest
returns ERROR_INVALID_HANDLE
for fReqQueueHandle=0
.
I attached the sample project HttpServerRacing.7z (424 Bytes) and a bit modified TROHttpThread.IntExecute
with
OutputDebugString(PChar(Format('TROHttpThread.IntExecute fOwner.fReqQueueHandle = %u', [fOwner.fReqQueueHandle])));
This results the following log in Delphi:
Hope I explained the bug
IMO to get a robust solution TROHttpThread.IntExecute has to be synched (e.g. with an event) with TROHttpServerApiServer.SetActive.
Best regards
Alexander
Thanks, logged as bugs://85706
bugs://85706 got closed with status fixed.
EvgenyK
(Evgeny Karpov)
March 10, 2021, 1:01pm
6
update uROHttpServerApiServer.pas
as
procedure TROHttpServerApiServer.SetThreadCnt(const Value: Integer);
..
if fActive then UpdateThreads(False); //<<<<<<<<changed
end;
end;