make SO_NOSIGPIPE more prominent
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Sat, 10 Aug 2019 19:41:05 +0000 (21:41 +0200)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Sat, 10 Aug 2019 19:41:05 +0000 (21:41 +0200)
src/util/network.c

index 90f8c8640ad5f70ff9f7a59090ea6a6649c9344c..2c16fe8c9ec39673e313e6f1f455f90f94599d96 100644 (file)
@@ -343,7 +343,7 @@ socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h)
  *
  * @param h the socket to make non-delaying
  */
-static void
+static int
 socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h)
 {
   int abs_value = 1;
@@ -352,7 +352,8 @@ socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h)
       setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE,
                   (const void *) &abs_value,
                   sizeof (abs_value)))
-    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 #endif
 
@@ -444,7 +445,14 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
     return GNUNET_SYSERR;
   }
 #ifdef DARWIN
-  socket_set_nosigpipe (h);
+  if (GNUNET_SYSERR == socket_set_nosigpipe (h))
+  {
+    eno = errno;
+    GNUNET_break (0);
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (h));
+    errno = eno;
+    return GNUNET_SYSERR;
+  }
 #endif
   if ( (type == SOCK_STREAM)
 #ifdef AF_UNIX