Skip to content

Commit

Permalink
fixed random blocking of async server
Browse files Browse the repository at this point in the history
- asynchronous and multi-thread programming is hard - race conditions could be difficult to track
- I spent a lot of time on this issue, which was reproduced using the wrk tool and a lot of concurrent connections for a long time
- it was more easily reproduced on Windows, but could potentially affect all platforms, and may be the culprit of very rare race condition on other platforms like Linux (seen e.g. on TFB)
- in fact, it was a one-liner - as often with race conditions :) - just move one flag assignment at the right place
  • Loading branch information
Arnaud Bouchez committed Aug 31, 2023
1 parent 828117b commit 060d5be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.1.5811'
'2.1.5812'
2 changes: 1 addition & 1 deletion src/net/mormot.net.async.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1869,8 +1869,8 @@ procedure TAsyncConnectionsThread.Execute;
atpReadPending:
// secondary threads wait, then read and process pending events
begin
fWaitForReadPending := true;
fEvent.ResetEvent;
fWaitForReadPending := true; // to be set just before WaitForEver
fEvent.WaitForEver;
if Terminated then
break;
Expand Down

0 comments on commit 060d5be

Please sign in to comment.