Safer handling of corner-cases in w32 select
authorLRN <lrn1986@gmail.com>
Fri, 13 Jul 2012 16:24:27 +0000 (16:24 +0000)
committerLRN <lrn1986@gmail.com>
Fri, 13 Jul 2012 16:24:27 +0000 (16:24 +0000)
src/util/network.c

index c61704be984df087c5f88fef44968af7e255a3d9..6d8b2869ab61b5503df5af5f33940ce16647ac16 100644 (file)
@@ -1523,10 +1523,22 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
   LOG (GNUNET_ERROR_TYPE_DEBUG, "nfds: %d, handles: %d, will wait: %llu ms\n", 
        nfds, nhandles, (unsigned long long) ms_total);
   if (nhandles)
+  {
     returncode =
         WaitForMultipleObjects (nhandles, handle_array, FALSE, ms_total);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "WaitForMultipleObjects Returned : %d\n",
-       returncode);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "WaitForMultipleObjects Returned : %d\n",
+         returncode);
+  }
+  else if (nfds > 0)
+  {
+    i = (int) WaitForSingleObject (select_finished_event, INFINITE);
+    returncode = WAIT_TIMEOUT;
+  }
+  else
+  {
+    /* Shouldn't come this far. If it does - investigate. */
+    GNUNET_assert (0);
+  }
 
   if (nfds > 0)
   {