diff options
author | Tamar Christina <tamar@zhox.com> | 2020-05-31 15:54:43 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-07-15 16:41:03 -0400 |
commit | 3ebd8ad9b1f7f77a928f2ff0d3e61ddfae068dd3 (patch) | |
tree | 4afd1a696e6fc82b2ad93a4e8603931e16549649 /rts/win32 | |
parent | 256299b13e17044d6904a85043130d13bc592a62 (diff) | |
download | haskell-3ebd8ad9b1f7f77a928f2ff0d3e61ddfae068dd3.tar.gz |
winio: Various fixes related to rebase and testdriver
Diffstat (limited to 'rts/win32')
-rw-r--r-- | rts/win32/AsyncWinIO.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/rts/win32/AsyncWinIO.c b/rts/win32/AsyncWinIO.c index 8a9a647160..70b4455c71 100644 --- a/rts/win32/AsyncWinIO.c +++ b/rts/win32/AsyncWinIO.c @@ -387,14 +387,22 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo finished overlapped entried belonging to the completed I/O requests. The number of read entries will be returned in NUM. - NOTE: This function isn't thread safe, but is intended to be called only - when requested by the I/O manager via notifyScheduler. In - that context it is thread safe as we're guaranteeing that the I/O - manager is blocked waiting for the read to happen followed by a - registerAlertableWait call. */ + We clear the outstanding request flag to prevent two threads from handling + the same payload early on. Failing this the final safe guard is in + processCompletions. */ OVERLAPPED_ENTRY* getOverlappedEntries (uint32_t *num) { - *num = num_last_completed; + AcquireSRWLockExclusive (&lock); + + if (outstanding_service_requests) + *num = num_last_completed; + else + *num = 0; + + outstanding_service_requests = false; + + ReleaseSRWLockExclusive (&lock); + return entries; } |