Skip to content

Commit 23cd119

Browse files
committed
network: on freebsd using SO_REUSEPORT_LB for a better distribution.
SO_REUSEPORT on FreeBSD acts differently as the underlying semantic is different (as it predates Linux) since it s more for UDP/multicasts. The SO_REUSEPORT_LB flag, however, uses load balancing for group of address:port combinations which is how Linux is implemented.
1 parent 3943bb0 commit 23cd119

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main/network.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
8787
# define PHP_TIMEOUT_ERROR_VALUE ETIMEDOUT
8888
#endif
8989

90+
#ifdef SO_REUSEPORT_LB
91+
// Historically, SO_REUSEPORT on FreeBSD predates Linux version
92+
// however does not involve load balancing grouping thus
93+
// SO_REUSEPORT_LB is the genuine equivalent.
94+
# undef SO_REUSEPORT
95+
# define SO_REUSEPORT SO_REUSEPORT_LB
96+
#endif
97+
9098
#ifdef HAVE_GETADDRINFO
9199
# if !defined(PHP_WIN32) && !defined(HAVE_GAI_STRERROR)
92100
/* {{{ php_gai_strerror */

0 commit comments

Comments
 (0)