- verboser log, faster start
[oweals/gnunet.git] / src / util / network.c
index 125eaca8bcce741686bc220180553cb6896476b6..bea6bfbb23ce7f9499cdb268e1d67c69344f2e38 100644 (file)
@@ -144,12 +144,13 @@ GNUNET_NETWORK_shorten_unixpath (char *unixpath)
 
 /**
  * Set if a socket should use blocking or non-blocking IO.
+ *
  * @param fd socket
  * @param doBlock blocking mode
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-static int
-socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int doBlock)
+int
+GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int doBlock)
 {
 
 #if MINGW
@@ -307,7 +308,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
     LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                   "socket_set_inheritable");
 
-  if (GNUNET_SYSERR == socket_set_blocking (h, GNUNET_NO))
+  if (GNUNET_SYSERR == GNUNET_NETWORK_socket_set_blocking (h, GNUNET_NO))
   {
     GNUNET_break (0);
     GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (h));
@@ -1450,10 +1451,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 
   /* Copy all the writes to the except, so we can detect connect() errors */
   for (i = 0; i < awrite.fd_count; i++)
-  {
-      if (awrite.fd_array[i] != 0 && awrite.fd_array[i] != -1)
-          FD_SET (awrite.fd_array[i], &aexcept);
-  }
+    FD_SET (awrite.fd_array[i], &aexcept);
   if (aread.fd_count > 0 || awrite.fd_count > 0 || aexcept.fd_count > 0)
     selectret = select (1, (rfds != NULL) ? &aread : NULL,
         (wfds != NULL) ? &awrite : NULL, &aexcept, &select_timeout);
@@ -1472,10 +1470,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
      have checked that descriptors were in awrite originally before re-adding them from
      aexcept. Luckily, GNUnet never uses aexcept for anything, so this does not become a problem (yet). */
   for (i = 0; i < aexcept.fd_count; i++)
-  {
-    if (aexcept.fd_array[i] != 0 && aexcept.fd_array[i] != -1)
-      FD_SET (aexcept.fd_array[i], &awrite);
-  }
+    FD_SET (aexcept.fd_array[i], &awrite);
 
   /* If our select returned something or is a 0-timed request, then also check the pipes and get out of here! */
   /* Sadly, it means code duplication :( */
@@ -1751,10 +1746,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
      * but we don't use OOB data.
      */
     for (i = 0; i < awrite.fd_count; i++)
-    {
-      if (awrite.fd_array[i] != 0 && awrite.fd_array[i] != -1)
-        FD_SET (awrite.fd_array[i], &aexcept);
-    }
+      FD_SET (awrite.fd_array[i], &aexcept);
     ResetEvent (select_finished_event);
     SetEvent (select_standby_event);
   }
@@ -1798,10 +1790,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
     }
     /* Check aexcept, add its contents to awrite */
     for (i = 0; i < aexcept.fd_count; i++)
-    {
-      if (aexcept.fd_array[i] != 0 && aexcept.fd_array[i] != -1)
-        FD_SET (aexcept.fd_array[i], &awrite);
-    }
+      FD_SET (aexcept.fd_array[i], &awrite);
   }
 
   returnedpos = returncode - WAIT_OBJECT_0;