]> jfr.im git - irc/blitzed-org/charybdis.git/commitdiff
libratbox: Allow defer_accept on FreeBSD.
authorJilles Tjoelker <redacted>
Mon, 19 Mar 2012 23:33:31 +0000 (00:33 +0100)
committerJilles Tjoelker <redacted>
Mon, 19 Mar 2012 23:33:31 +0000 (00:33 +0100)
Note that you must have options ACCEPT_FILTER_DATA in your kernel
configuration or load the accf_data kernel module. The functionality is
not in the GENERIC kernel.

libratbox/src/commio.c

index ca8226493cbcb83c4ec364960210f2c3fca9769e..92e9d387e9d18560c744f3972f758fa7123f53b1 100644 (file)
@@ -774,6 +774,17 @@ rb_listen(rb_fde_t *F, int backlog, int defer_accept)
                setsockopt(F->fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &backlog, sizeof(int));
        }
 #endif
+#ifdef SO_ACCEPTFILTER
+       if (defer_accept && !result)
+       {
+               struct accept_filter_arg afa;
+
+               memset(&afa, '\0', sizeof afa);
+               rb_strlcpy(afa.af_name, "dataready", sizeof afa.af_name);
+               (void)setsockopt(F->fd, SOL_SOCKET, SO_ACCEPTFILTER, &afa,
+                               sizeof afa);
+       }
+#endif
 
        return result;
 }