mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
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. Co-authored-by: Jakub Zelenka <bukka@php.net>
This commit is contained in:
committed by
Jakub Zelenka
parent
aead67d0bb
commit
f900035b27
@@ -512,7 +512,13 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po
|
||||
#endif
|
||||
#ifdef SO_REUSEPORT
|
||||
if (sockopts & STREAM_SOCKOP_SO_REUSEPORT) {
|
||||
# ifdef SO_REUSEPORT_LB
|
||||
/* Historically, SO_REUSEPORT on FreeBSD predates Linux version, however does not
|
||||
* involve load balancing grouping thus SO_REUSEPORT_LB is the genuine equivalent.*/
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEPORT_LB, (char*)&sockoptval, sizeof(sockoptval));
|
||||
# else
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (char*)&sockoptval, sizeof(sockoptval));
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
#ifdef SO_BROADCAST
|
||||
|
||||
Reference in New Issue
Block a user