[Git][ghc/ghc][master] winio: fixed timeouts non-threaded.

Marge Bot gitlab at gitlab.haskell.org
Fri Oct 9 12:49:37 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00
winio: fixed timeouts non-threaded.

- - - - -


1 changed file:

- rts/win32/AsyncWinIO.c


Changes:

=====================================
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;
@@ -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;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c832f7e2a9314cfd61257cb161b1795b612d12b5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c832f7e2a9314cfd61257cb161b1795b612d12b5
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201009/df47d7fb/attachment-0001.html>


More information about the ghc-commits mailing list