Commit c832f7e2 authored by Tamar Christina's avatar Tamar Christina Committed by Marge Bot

winio: fixed timeouts non-threaded.

parent 9657f6f3
......@@ -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;
......@@ -342,15 +339,15 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo
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;
......@@ -365,7 +362,7 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo
/* 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;
......@@ -373,9 +370,9 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo
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) {
......@@ -394,7 +391,7 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo
registerAlertableWait call. */
OVERLAPPED_ENTRY* getOverlappedEntries (uint32_t *num)
{
*num = num_last_completed;
*num = num_notify;
return entries;
}
......@@ -428,8 +425,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);
}
......@@ -454,7 +451,6 @@ bool queueIOThread()
if(canQueueIOThread)
{
ASSERT(!outstanding_service_requests);
num_last_completed = num_notify;
outstanding_service_requests = true;
canQueueIOThread = false;
Capability *cap = &MainCapability;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment