Skip to content

Commit 02126e8

Browse files
authored
tcp_defer_accept option support for FreeBSD. (swoole#4049)
SO_ACCEPTFILER acts similarly as Linux's TCP_DEFER_ACCEPT.
1 parent 91704ac commit 02126e8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/server/port.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ int ListenPort::listen() {
166166
}
167167
#endif
168168

169+
#ifdef SO_ACCEPTFILTER
170+
if (tcp_defer_accept) {
171+
struct accept_filter_arg a;
172+
memset(&a, 0, sizeof(a));
173+
strcpy(a.af_name, "httpready");
174+
if (socket->set_option(SOL_SOCKET, SO_ACCEPTFILTER, &a, sizeof(a)) != 0) {
175+
swSysWarn("setsockopt(SO_ACCEPTFILTER) failed");
176+
}
177+
}
178+
#endif
179+
169180
#ifdef TCP_FASTOPEN
170181
if (tcp_fastopen) {
171182
if (socket->set_option(IPPROTO_TCP, TCP_FASTOPEN, tcp_fastopen) != 0) {

0 commit comments

Comments
 (0)