Hi,
On 05/11/2017 09:51 AM, Baptiste wrote:
Hi Lukas,
Thanks a lot!
So, after the fork(), HAProxy closes the UDP socket (4) and open a new
one (1) as expected, that said, the scheduler still points to the old one.
Obviously, this behavior doesn't happen on Linux.
socket #4 has been closed() but not removed from kevent fd set...
I'll see how I can reproduce the issue and then fix it. That said, I'm
running a bit out of time for now.
I have reproduced (at home) the stats socket issue within a FreeBSD 9.3 VM.
Replacing your call to close() by fd_delete() which removes the fd from
the fd set used by kevent *and close it* seems to fix at least the stats
socket issue. I do not know if there are remaining ones.
I did not reproduced the kevent issue revealed by Lukas traces. But I
had other ones : ERR#57 'Socket is not connected' during sendto().
I attached a temporary patch to be validated and to let you perhaps
provide a better one as I have not double check everything.
I hope this will help.
Regards,
Fred.
diff --git a/src/dns.c b/src/dns.c
index a118598..cb0a9a9 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -1004,7 +1004,7 @@ int dns_init_resolvers(int close_socket)
if (close_socket == 1) {
if (curnameserver->dgram) {
- close(curnameserver->dgram->t.sock.fd);
+ fd_delete(curnameserver->dgram->t.sock.fd);
memset(curnameserver->dgram, '\0', sizeof(*dgram));
dgram = curnameserver->dgram;
}