]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] convert all signals to asynchronous signals
authorWilly Tarreau <w@1wt.eu>
Sun, 10 May 2009 07:59:50 +0000 (09:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 10 May 2009 07:59:50 +0000 (09:59 +0200)
The small list of signals currently handled by haproxy were processed
as soon as they were received. This has caused trouble with calls to
pool_gc2() occuring in the middle of libc's memory management functions
seldom causing deadlocks preventing the old process from leaving.

Now these signals use the new async signal framework and are called
asynchronously, when there is no risk of recursion. This ensures more
reliable operation, especially for sensible processing such as memory
management.

src/haproxy.c

index 608dcc5783161edf5bcbb1647c37cf180d29866f..31c48e1c0584660e7ea9dce37a1fdc1baa7d9cc7 100644 (file)
@@ -244,7 +244,7 @@ void sig_soft_stop(int sig)
 {
        soft_stop();
        pool_gc2();
-       signal(sig, SIG_IGN);
+       signal_register(sig, SIG_IGN);
 }
 
 /*
@@ -254,7 +254,6 @@ void sig_pause(int sig)
 {
        pause_proxies();
        pool_gc2();
-       signal(sig, sig_pause);
 }
 
 /*
@@ -263,7 +262,6 @@ void sig_pause(int sig)
 void sig_listen(int sig)
 {
        listen_proxies();
-       signal(sig, sig_listen);
 }
 
 /*
@@ -313,7 +311,6 @@ void sig_dump_state(int sig)
 
                p = p->next;
        }
-       signal(sig, sig_dump_state);
 }
 
 void dump(int sig)
@@ -361,8 +358,8 @@ void sig_int(int sig)
        */
        fast_stop();
        pool_gc2();
-       /* If we are killed twice, we decide to die*/
-       signal(sig, SIG_DFL);
+       /* If we are killed twice, we decide to die */
+       signal_register(sig, SIG_DFL);
 }
 
 void sig_term(int sig)
@@ -374,8 +371,8 @@ void sig_term(int sig)
        */
        fast_stop();
        pool_gc2();
-       /* If we are killed twice, we decide to die*/
-       signal(sig, SIG_DFL);
+       /* If we are killed twice, we decide to die */
+       signal_register(sig, SIG_DFL);
 }
 #endif
 
@@ -909,12 +906,12 @@ int main(int argc, char **argv)
        FILE *pidfile = NULL;
        init(argc, argv);
 
-       signal(SIGQUIT, dump);
-       signal(SIGUSR1, sig_soft_stop);
-       signal(SIGHUP, sig_dump_state);
+       signal_register(SIGQUIT, dump);
+       signal_register(SIGUSR1, sig_soft_stop);
+       signal_register(SIGHUP, sig_dump_state);
 #ifdef DEBUG_MEMORY
-       signal(SIGINT, sig_int);
-       signal(SIGTERM, sig_term);
+       signal_register(SIGINT, sig_int);
+       signal_register(SIGTERM, sig_term);
 #endif
 
        /* on very high loads, a sigpipe sometimes happen just between the
@@ -974,8 +971,8 @@ int main(int argc, char **argv)
        }
 
        /* prepare pause/play signals */
-       signal(SIGTTOU, sig_pause);
-       signal(SIGTTIN, sig_listen);
+       signal_register(SIGTTOU, sig_pause);
+       signal_register(SIGTTIN, sig_listen);
 
        /* MODE_QUIET can inhibit alerts and warnings below this line */