BUG/MEDIUM: mworker: fix segv in early failure of mworker mode with peers
During an early failure of the mworker mode, the
mworker_cleanlisteners() function is called and tries to cleanup the
peers, however the peers are in a semi-initialized state and will use
NULL pointers.
The fix check the variable before trying to use them.
Bug revealed in issue #1956.
Could be backported as far as 2.0.
(cherry picked from commit 035058e8bfe4fc731b2ede8fcdc2b8d14c4936ce)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 661557989e3a8d84d18c997ebdabb26146ebe8ad)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 360b26a15dca2f1c01007b08a67dec7f062e80d4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 352e6a4501cf36c3fdad1e0af0754fa3f766d7d7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/mworker.c b/src/mworker.c
index d4ba7d8..d78f4ce 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -423,8 +423,10 @@
stop_proxy(curpeers->peers_fe);
/* disable this peer section so that it kills itself */
- signal_unregister_handler(curpeers->sighandler);
- task_destroy(curpeers->sync_task);
+ if (curpeers->sighandler)
+ signal_unregister_handler(curpeers->sighandler);
+ if (curpeers->sync_task)
+ task_destroy(curpeers->sync_task);
curpeers->sync_task = NULL;
task_destroy(curpeers->peers_fe->task);
curpeers->peers_fe->task = NULL;