mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MINOR: sock_inet: use SO_REUSEPORT_LB where available
On FreeBSD 13.1 I noticed that thread balancing using shards was not always working. Sometimes several threads would work, but most of the time a single one was taking all the traffic. This is related to how SO_REUSEPORT works on FreeBSD since version 12, as it seems there is no guarantee that multiple sockets will receive the traffic. However there is SO_REUSEPORT_LB that is designed exactly for this, so we'd rather use it when available. This patch may possibly be backported, but nobody complained and it's not sure that many users rely on shards. So better wait for some feedback before backporting this.
This commit is contained in:
parent
ccf8012f28
commit
9f53b7b41a
@ -380,6 +380,14 @@ int sock_inet_bind_receiver(struct receiver *rx, char **errmsg)
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one));
|
||||
#endif
|
||||
|
||||
#ifdef SO_REUSEPORT_LB
|
||||
/* FreeBSD 12 and above use this to load-balance incoming connections.
|
||||
* This is limited to 256 listeners per group however.
|
||||
*/
|
||||
if (!ext && (global.tune.options & GTUNE_USE_REUSEPORT))
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, &one, sizeof(one));
|
||||
#endif
|
||||
|
||||
if (!ext && (rx->settings->options & RX_O_FOREIGN)) {
|
||||
switch (addr_inet.ss_family) {
|
||||
case AF_INET:
|
||||
|
Loading…
Reference in New Issue
Block a user