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.
This commit is contained in:
Jilles Tjoelker 2012-03-20 00:33:31 +01:00
parent 521f9d63a9
commit 797a29f353

View 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)); setsockopt(F->fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &backlog, sizeof(int));
} }
#endif #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; return result;
} }