gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9166 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r9166 - gnunet/src/util
Date: Sat, 17 Oct 2009 23:10:41 -0600

Author: holindho
Date: 2009-10-17 23:10:41 -0600 (Sat, 17 Oct 2009)
New Revision: 9166

Modified:
   gnunet/src/util/network.c
Log:
don't repeat setsockopt on every send


Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c   2009-10-17 21:20:13 UTC (rev 9165)
+++ gnunet/src/util/network.c   2009-10-18 05:10:41 UTC (rev 9166)
@@ -102,7 +102,7 @@
 
 #ifndef MINGW
 /**
- * Make a non-inheritable to child processes
+ * Make a socket non-inheritable to child processes
  *
  * @param h the socket to make non-inheritable
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
@@ -124,7 +124,24 @@
 
 
 
+#ifdef OSX
 /**
+ * The MSG_NOSIGNAL equivalent on Mac OS X
+ *
+ * @param h the socket to make non-delaying
+ */
+static void
+socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle
+                   *h)
+{
+  int value = 1;
+  setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value));
+}
+#endif
+
+
+
+/**
  * Disable delays when sending data via the socket.
  * (GNUnet makes sure that messages are as big as
  * possible already).
@@ -187,6 +204,9 @@
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                         "socket_set_inheritable");
 #endif
+#ifdef OSX
+  socket_set_nosigpipe (ret);  
+#endif
   socket_set_nodelay (ret);
   return ret;
 }
@@ -351,13 +371,6 @@
 {
   int ret;
   int flags;
-#ifdef OSX
-  int no_sigpipe;
-  no_sigpipe = 1;
-  /* shouldn't matter if this fails as there's a SIGPIPE handler */
-  ret = setsockopt (desc->fd, SOL_SOCKET, SO_NOSIGPIPE,
-                    (void *) &no_sigpipe, sizeof (no_sigpipe));
-#endif
 
   flags = 0;
 #ifdef MSG_DONTWAIT
@@ -395,13 +408,6 @@
 {
   int ret;
   int flags;
-#ifdef OSX
-  int no_sigpipe;
-  no_sigpipe = 1;
-  /* shouldn't matter if this fails as there's a SIGPIPE handler */
-  ret = setsockopt (desc->fd, SOL_SOCKET, SO_NOSIGPIPE,
-                    (void *) &no_sigpipe, sizeof (no_sigpipe));
-#endif
 
   flags = 0;
 #ifdef MSG_DONTWAIT
@@ -494,6 +500,9 @@
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                         "socket_set_inheritable");
 #endif
+#ifdef OSX
+  socket_set_nosigpipe (ret);  
+#endif
   if (type == SOCK_STREAM)
     socket_set_nodelay (ret);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]