cleaning
authorChristian Grothoff <christian@grothoff.org>
Wed, 23 Jun 2010 14:23:10 +0000 (14:23 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 23 Jun 2010 14:23:10 +0000 (14:23 +0000)
src/util/network.c

index 4a287ada9bcd9e0beffad04535b15310964e951f..69b36bc51b981c173678db76a14c8f53b97173bb 100644 (file)
@@ -142,11 +142,16 @@ static int
 socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h)
 {
   int i;
-  i = fcntl (h->fd, F_GETFD);
+
+  i = fcntl (h->fd, F_GETFD);  
+  if (i < 0)
+    return GNUNET_SYSERR;
   if (i == (i | FD_CLOEXEC))
     return GNUNET_OK;
-  return (fcntl (h->fd, F_SETFD, i | FD_CLOEXEC) == 0)
-    ? GNUNET_OK : GNUNET_SYSERR;
+  i |= FD_CLOEXEC;
+  if (fcntl (h->fd, F_SETFD, i) < 0)
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 #endif