summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2020-10-06 09:55:19 +0100
committerBen Gamari <ben@smart-cactus.org>2020-11-09 14:15:16 -0500
commitc3a8c0bf73e4e837f8c467f4a1310441eceed33b (patch)
treeb5f2e4317b7be48fce06f10db9dfa3a06f3c8c1a /rts
parent556c2356bb987a851960673bb85044eaeb15e778 (diff)
downloadhaskell-c3a8c0bf73e4e837f8c467f4a1310441eceed33b.tar.gz
winio: fixed timeouts non-threaded.
(cherry picked from commit c832f7e2a9314cfd61257cb161b1795b612d12b5)
Diffstat (limited to 'rts')
-rw-r--r--rts/win32/AsyncWinIO.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/rts/win32/AsyncWinIO.c b/rts/win32/AsyncWinIO.c
index 56f804e97b..660a687f99 100644
--- a/rts/win32/AsyncWinIO.c
+++ b/rts/win32/AsyncWinIO.c
@@ -203,9 +203,6 @@ static CONDITION_VARIABLE threadIOWait;
static uint32_t num_callbacks = 32;
/* Buffer for I/O request information. */
static OVERLAPPED_ENTRY *entries;
-/* Number of I/O calls verified to have completed in the last round by the
- Haskell I/O Manager. */
-static uint32_t num_last_completed;
/* Notify the Haskell side of this many new finished requests */
static uint32_t num_notify;
@@ -335,15 +332,15 @@ void registerAlertableWait (bool has_timeout, DWORD mssec)
bool interrupt = false;
- if (num_req == 0 && !has_timeout) {
+ if (mssec == 0 && !has_timeout) {
timeout = INFINITE;
}
else if(has_timeout) {
timeout = mssec;
}
- outstanding_service_requests = pending_service;
+ outstanding_service_requests = false;
- //Resize queue if required
+ /* Resize queue if required. */
if (queue_full)
{
num_callbacks *= 2;
@@ -358,7 +355,7 @@ void registerAlertableWait (bool has_timeout, DWORD mssec)
/* If the new timeout is earlier than the old one we have to reschedule the
wait. Do this by interrupting the current operation and setting the new
timeout, since it must be the shortest one in the queue. */
- if (timeout > mssec)
+ if (timeout > mssec && mssec > 0)
{
timeout = mssec;
interrupt = true;
@@ -366,9 +363,9 @@ void registerAlertableWait (bool has_timeout, DWORD mssec)
ReleaseSRWLockExclusive (&wio_runner_lock);
- // Since we call registerAlertableWait only after
- // processing I/O requests it's always desireable to wake
- // up the runner here.
+ /* Since we call registerAlertableWait only after
+ processing I/O requests it's always desireable to wake
+ up the runner here. */
WakeConditionVariable (&wakeEvent);
if (interrupt) {
@@ -387,7 +384,7 @@ void registerAlertableWait (bool has_timeout, DWORD mssec)
registerAlertableWait call. */
OVERLAPPED_ENTRY* getOverlappedEntries (uint32_t *num)
{
- *num = num_last_completed;
+ *num = num_notify;
return entries;
}
@@ -421,8 +418,8 @@ void awaitAsyncRequests (bool wait)
static void notifyScheduler(uint32_t num) {
AcquireSRWLockExclusive (&wio_runner_lock);
ASSERT(!canQueueIOThread);
- canQueueIOThread = true;
num_notify = num;
+ canQueueIOThread = true;
WakeConditionVariable(&threadIOWait);
ReleaseSRWLockExclusive (&wio_runner_lock);
}
@@ -447,7 +444,6 @@ bool queueIOThread()
if(canQueueIOThread)
{
ASSERT(!outstanding_service_requests);
- num_last_completed = num_notify;
outstanding_service_requests = true;
canQueueIOThread = false;
Capability *cap = &MainCapability;