Listen socket closed after reloading by SIGUSR2

Hi guys,

I have installed haproxy 1.8.1, and here is my configuration file.

global
    daemon
    maxconn 100 
    master-worker no-exit-on-failure
    
defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms
    
backend gateway
    balance roundrobin
    server server1 172.16.0.42:8088
    
frontend gateway
    bind unix@/tmp/gateway.socket
    default_backend gateway

I can connect to /tmp/gateway.socket with netcat.
Then I reload the worker by send a SIGUSR2 to the master process.
I can’t connect to /tmp/gateway.socket after the reloading.

The listen socket fd was the same as stdout.

lrwx------ 1 sagaxu sagaxu 64 Dec 21 18:07 0 -> anon_inode:[eventpoll]
lrwx------ 1 sagaxu sagaxu 64 Dec 21 18:07 1 -> socket:[17192229]
lr-x------ 1 sagaxu sagaxu 64 Dec 21 18:07 5 -> pipe:[17154247]
l-wx------ 1 sagaxu sagaxu 64 Dec 21 18:07 6 -> pipe:[17154247]

It was probably closed by the fclose clauses in haproxy.c
fclose(stdin); fclose(stdout); fclose(stderr);

thanks for your attention.

Thanks for this report, I do believe this is a bug.

I bisected this to commit baf6ea4b (" BUG/MINOR: mworker: detach from tty when in daemon mode") which indeed contains the triple fclose() you mentioned above:

http://git.haproxy.org/?p=haproxy.git;a=commitdiff;h=baf6ea4bd5c6df7b9f91a612fb068df63b3d1eec

I’ve reported this to the ML and CC’ed Author and mworker maintainer, you can follow the process on the mailing list or on mail-archive via:

https://www.mail-archive.com/haproxy@formilux.org/msg28372.html

A quick workaround is to put the keyword “quiet” in the global section.

The discussion about a proper bugfix is ongoing.

This is fixed in v1.8.3.