gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3954 - in GNUnet/src: transports util/network


From: grothoff
Subject: [GNUnet-SVN] r3954 - in GNUnet/src: transports util/network
Date: Sun, 17 Dec 2006 13:49:09 -0800 (PST)

Author: grothoff
Date: 2006-12-17 13:49:06 -0800 (Sun, 17 Dec 2006)
New Revision: 3954

Modified:
   GNUnet/src/transports/tcp_old.c
   GNUnet/src/util/network/io.c
Log:
OS X improvements from Heikki

Modified: GNUnet/src/transports/tcp_old.c
===================================================================
--- GNUnet/src/transports/tcp_old.c     2006-12-17 12:35:44 UTC (rev 3953)
+++ GNUnet/src/transports/tcp_old.c     2006-12-17 21:49:06 UTC (rev 3954)
@@ -580,8 +580,13 @@
 #elif SOLARIS
     flags = MSG_DONTWAIT;
 #elif OSX
-    /* As braindead as Win32? */
-    flags = 0;
+    {
+    int __tmp = 1;
+    if (setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, 
+        (void *)&__tmp, sizeof(__tmp)) < 0)
+      printf("setsockopt failed\n");
+    }
+    flags = MSG_DONTWAIT;
 #elif CYGWIN
        flags = MSG_NOSIGNAL;
 #elif LINUX
@@ -1005,10 +1010,12 @@
   if (sock == -1) {
     return SYSERR;
   }
+#ifndef OSX
   if (0 != setBlocking(sock, NO)) {
     CLOSE(sock);
     return SYSERR;
   }
+#endif
   memset(&soaddr,
         0,
         sizeof(soaddr));

Modified: GNUnet/src/util/network/io.c
===================================================================
--- GNUnet/src/util/network/io.c        2006-12-17 12:35:44 UTC (rev 3953)
+++ GNUnet/src/util/network/io.c        2006-12-17 21:49:06 UTC (rev 3954)
@@ -141,6 +141,16 @@
 }
 
 /* TODO: log errors! */
+#ifdef OSX
+static int socket_set_nosigpipe(struct SocketHandle * s,
+                                int dontSigPipe) {
+  return setsockopt(s->handle, SOL_SOCKET, SO_NOSIGPIPE,
+                    (void *)&dontSigPipe, 
+                    sizeof(dontSigPipe));
+}
+#endif
+
+/* TODO: log errors! */
 int socket_set_blocking(struct SocketHandle * s,
                        int doBlock) {
 #if MINGW
@@ -193,7 +203,9 @@
   if (0 == (nc & NC_IgnoreInt))
     flags |= MSG_NOSIGNAL;
 #elif OSX
-  /* anything? */
+  socket_set_nosigpipe(s, 0 != (nc & NC_IgnoreInt));
+  if (0 == (nc & NC_Blocking))
+    flags |= MSG_DONTWAIT;
 #elif SOMEBSD || SOLARIS
   if (0 == (nc & NC_Blocking))
     flags |= MSG_DONTWAIT;
@@ -267,7 +279,9 @@
   if (0 == (nc & NC_IgnoreInt))
     flags |= MSG_NOSIGNAL;
 #elif OSX
-  /* anything? */
+  socket_set_nosigpipe(s, 0 != (nc & NC_IgnoreInt));
+  if (0 == (nc & NC_Blocking))
+    flags |= MSG_DONTWAIT;
 #elif SOMEBSD || SOLARIS
   if (0 == (nc & NC_Blocking))
     flags |= MSG_DONTWAIT;
@@ -341,7 +355,9 @@
   if (0 == (nc & NC_Blocking))
     flags |= MSG_DONTWAIT;
 #elif OSX
-  /* As braindead as Win32? */
+  socket_set_nosigpipe(s, 0 != (nc & NC_IgnoreInt));
+  if (0 == (nc & NC_Blocking))
+    flags |= MSG_DONTWAIT;
 #elif CYGWIN
   if (0 == (nc & NC_IgnoreInt))
     flags |= MSG_NOSIGNAL;
@@ -416,7 +432,9 @@
   if (0 == (nc & NC_Blocking))
     flags |= MSG_DONTWAIT;
 #elif OSX
-  /* As braindead as Win32? */
+  socket_set_nosigpipe(s, 0 != (nc & NC_IgnoreInt));
+  if (0 == (nc & NC_Blocking))
+    flags |= MSG_DONTWAIT;
 #elif CYGWIN
   if (0 == (nc & NC_IgnoreInt))
     flags |= MSG_NOSIGNAL;





reply via email to

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