I have a HttpServer based on
When testing the configuration “localHttpServer + localHttpClient”, I met strange delays (15-20ms) even for dummy calls that “do nothing”.
My further research showed that the reason is in
1 Removing the
sleep(1) resolves the issue
procedure TROHttpThread.IntExecute; begin ... else break; // unknown error end; // sleep(1); // <--- The patched line end; finally FreeMem(lRequestBuffer); end; end;
As I see the idea of the sleep(1) is to switch execution from the current thread.
Q1: Does removing the sleep(1) break something?
2 As well I noticed strange
ERROR_IO_PENDING: begin // If the function is being used asynchronously, a return value of ERROR_IO_PENDING // indicates that the next request is not yet ready and will be retrieved later // through normal overlapped I/O completion mechanisms. sleep(100); end;
I don’t see the reason why to sleep here if the call
lRes := HttpServerAPI.ReceiveHttpRequest(fOwner.fReqQueueHandle, ...,lReceivedBytes);
is synchronous and will block execution anyway.
Q2: Could sleep(100) be omitted here?