From: Willy Tarreau Date: Tue, 9 Jun 2009 12:36:00 +0000 (+0200) Subject: [BUG] ensure that we correctly re-start old process in case of error X-Git-Tag: v1.3.14.14~5 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=fe228040a1307fcc71e42861a44cf592763f6458;p=haproxy.git [BUG] ensure that we correctly re-start old process in case of error When a new process fails to grab some ports, it sends a signal to the old process in order to release them. Then it tries to bind again. If it still fails (eg: one of the ports is bound to a completely different process), it must send the continue signal to the old process so that this one re-binds to the ports. This is correctly done, but the newly bound ports are not released first, which sometimes causes the old process to remain running with no port bound. The fix simply consists in unbinding all ports before sending the signal to the old process. (cherry picked from commit f68da4603a092f35af627c459dbc714d9fa796e9) (cherry picked from commit f20cad6b3214f2b1b3db7fbeeecc0ef109185c2d) (cherry picked from commit 83a1540ec51d20697b6c6f86e63dc5e82efc0b72) --- diff --git a/src/haproxy.c b/src/haproxy.c index 9aeb79871..7804872f2 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -871,8 +871,10 @@ int main(int argc, char **argv) /* Note: start_proxies() sends an alert when it fails. */ if ((err & ~ERR_WARN) != ERR_NONE) { - if (retry != MAX_START_RETRIES && nb_oldpids) + if (retry != MAX_START_RETRIES && nb_oldpids) { + protocol_unbind_all(); /* cleanup everything we can */ tell_old_pids(SIGTTIN); + } exit(1); }