Forward port SOCKSENDBUF, SOCKRECVBUF features from 2.10.11.
[ircu2.10.12-pk.git] / ircd / os_openbsd.c
index 88a3cd12a398ada400b48dfe30c892f302440e5a..27c5ded8c1cbec2ecc4a57dffa3e08eb52ceef28 100644 (file)
@@ -19,6 +19,8 @@
  * $Id$
  *
  */
+#include "config.h"
+
 #define _XOPEN_SOURCE /* Need this for IOV_MAX */
 
 /* These typedef's are needed for socket.h to be happy. Bleep PROMISES to make
@@ -30,7 +32,6 @@ typedef unsigned int u_int;
 typedef unsigned long u_long;
 
 #include "ircd_osdep.h"
-#include "config.h"
 #include "msgq.h"
 
 #include <assert.h>
@@ -215,13 +216,14 @@ int os_set_reuseaddr(int fd)
                           (const char*) &opt, sizeof(opt)));
 }
 
-int os_set_sockbufs(int fd, unsigned int size)
+int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize)
 {
-  unsigned int opt = size;
+  unsigned int sopt = ssize;
+  unsigned int ropt = rsize;
   return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 
-                          (const char*) &opt, sizeof(opt)) &&
+                          (const char*) &ropt, sizeof(ropt)) &&
           0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 
-                          (const char*) &opt, sizeof(opt)));
+                          (const char*) &sopt, sizeof(sopt)));
 }
 
 int os_set_tos(int fd,int tos)
@@ -366,13 +368,11 @@ IOResult os_sendv_nonb(int fd, struct MsgQ* buf, unsigned int* count_in,
   return IO_FAILURE;
 }
 
-int os_connect_nonb(int fd, const struct sockaddr_in* sin)
+IOResult os_connect_nonb(int fd, const struct sockaddr_in* sin)
 {
-  if (connect(fd, (struct sockaddr*) sin, sizeof(struct sockaddr_in))) {
-    if (errno != EINPROGRESS)
-      return 0;
-  }
-  return 1;
+  if (connect(fd, (struct sockaddr*) sin, sizeof(struct sockaddr_in)))
+    return (errno == EINPROGRESS) ? IO_BLOCKED : IO_FAILURE;
+  return IO_SUCCESS;
 }
       
 int os_get_sockname(int fd, struct sockaddr_in* sin_out)