mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-02-15 22:31:29 +01:00
MEDIUM: listener: provide a fallback for accept4() when not supported
It happens that on some systems, the libc is recent enough to permit building with accept4() but the kernel does not support it. The result is then a disaster since no connection is accepted. We now detect this and automatically fall back to accept() and fcntl() when this happens.
This commit is contained in:
parent
a068a2951d
commit
6b3b0d4736
@ -311,6 +311,11 @@ void listener_accept(int fd)
|
||||
|
||||
#ifdef USE_ACCEPT4
|
||||
cfd = accept4(fd, (struct sockaddr *)&addr, &laddr, SOCK_NONBLOCK);
|
||||
if (unlikely(cfd == -1 && errno == EINVAL)) {
|
||||
/* unsupported syscall, fallback to normal accept()+fcntl() */
|
||||
if ((cfd = accept(fd, (struct sockaddr *)&addr, &laddr)) != -1)
|
||||
fcntl(cfd, F_SETFL, O_NONBLOCK);
|
||||
}
|
||||
#else
|
||||
cfd = accept(fd, (struct sockaddr *)&addr, &laddr);
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user