From 797a29f353cbde0ba94d81afcc58ee96025bd753 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Tue, 20 Mar 2012 00:33:31 +0100 Subject: [PATCH] libratbox: Allow defer_accept on FreeBSD. 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libratbox/src/commio.c b/libratbox/src/commio.c index ca822649..92e9d387 100644 --- a/libratbox/src/commio.c +++ b/libratbox/src/commio.c @@ -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; }