From: jenny-cheung Date: Sun, 18 Jul 2021 08:40:57 +0000 (+0800) Subject: MINOR: deinit: always deinit the init_mutex on failed initialization X-Git-Tag: v2.5-dev3~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=048368ef6;p=thirdparty%2Fhaproxy.git MINOR: deinit: always deinit the init_mutex on failed initialization The init_mutex was not unlocked in case an error is encountered during a thread initialization, and the polling loop was aborted during startup. In practise it does not have any observable effect since an explicit exit() is placed there, but it could confuse some debugging tools or some static analysers, so let's release it as expected. This addresses issue #1326. --- diff --git a/src/haproxy.c b/src/haproxy.c index d6aeed9067..79d457ad43 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2739,6 +2739,7 @@ static void *run_thread_poll_loop(void *data) list_for_each_entry(ptaf, &per_thread_alloc_list, list) { if (!ptaf->fct()) { ha_alert("failed to allocate resources for thread %u.\n", tid); + pthread_mutex_unlock(&init_mutex); exit(1); } } @@ -2750,6 +2751,7 @@ static void *run_thread_poll_loop(void *data) list_for_each_entry(ptif, &per_thread_init_list, list) { if (!ptif->fct()) { ha_alert("failed to initialize thread %u.\n", tid); + pthread_mutex_unlock(&init_mutex); exit(1); } }