[svn] w32pth - r33 - trunk

svn author wk cvs at cvs.gnupg.org
Fri Feb 26 11:34:34 CET 2010


Author: wk
Date: 2010-02-26 11:34:34 +0100 (Fri, 26 Feb 2010)
New Revision: 33

Modified:
   trunk/ChangeLog
   trunk/w32-pth.c
Log:
Fix for an empty timer list


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-02-25 19:47:37 UTC (rev 32)
+++ trunk/ChangeLog	2010-02-26 10:34:34 UTC (rev 33)
@@ -1,3 +1,8 @@
+2010-02-26  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.c (w32ce_timer_thread): Take care of an empty timer
+	list.
+
 2010-02-25  Werner Koch  <wk at g10code.com>
 
 	* utils.h: New.

Modified: trunk/w32-pth.c
===================================================================
--- trunk/w32-pth.c	2010-02-25 19:47:37 UTC (rev 32)
+++ trunk/w32-pth.c	2010-02-26 10:34:34 UTC (rev 33)
@@ -510,7 +510,7 @@
 static DWORD CALLBACK 
 w32ce_timer_thread (void *arg)
 {
-  int idx;
+  int idx, any;
   DWORD timeout, elapsed, lasttick;
 
   (void)arg;
@@ -521,28 +521,31 @@
       elapsed = lasttick;  /* Get start time.  */
       timeout = 0;
       EnterCriticalSection (&w32ce_timer_cs);
-      for (idx=0; idx < DIM (w32ce_timer); idx++)
+      for (idx=any=0; idx < DIM (w32ce_timer); idx++)
         {
-          if (w32ce_timer[idx].event && w32ce_timer[idx].active
-              && w32ce_timer[idx].remaining > timeout)
-            timeout = w32ce_timer[idx].remaining;
+          if (w32ce_timer[idx].event && w32ce_timer[idx].active)
+            {
+              any = 1;
+              if (w32ce_timer[idx].remaining > timeout)
+                timeout = w32ce_timer[idx].remaining;
+            }
         }
       LeaveCriticalSection (&w32ce_timer_cs);
-      if (timeout > 0x7fffffff)
+      if (!any)
+        timeout = INFINITE;
+      else if (timeout > 0x7fffffff)
         timeout = 0x7fffffff;
       switch (WaitForSingleObject (w32ce_timer_ev, (DWORD)timeout))
         {
         case WAIT_OBJECT_0:
-          break;
         case WAIT_TIMEOUT:
           break;
-        case WAIT_FAILED:
+        default:
           if (DBG_ERROR)
             fprintf (dbgfp, 
                      "%s:w32ce_timer_thread: WFSO failed: rc=%d\n",
                      log_get_prefix (NULL), (int)GetLastError ());
-          /* This is likely to happen if a handle has been closed
-             while we are waiting for it.  */
+          Sleep (500); /* Failsafe pause. */
           break;
         }
       EnterCriticalSection (&w32ce_timer_cs);




More information about the Gnupg-commits mailing list