From f0fdf94d84cea6b99cb3d1ee5c0d9f294afa1b28 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Mon, 8 Jul 2024 09:33:08 +0200 Subject: [PATCH] unlock mutex in case of `zend_bailout` --- src/parallel.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/parallel.c b/src/parallel.c index e220a4a..4ea38fe 100644 --- a/src/parallel.c +++ b/src/parallel.c @@ -232,6 +232,13 @@ PHP_RSHUTDOWN_FUNCTION(PARALLEL_CORE) PHP_RSHUTDOWN(PARALLEL_COPY)(INIT_FUNC_ARGS_PASSTHRU); + // In case of a `zend_bailout()` this mutex could still be locked, so we + // unlock it just in case. + // See https://github.com/krakjoe/parallel/issues/313 for more details + if (CG(unclean_shutdown) == 1) { + pthread_mutex_unlock(&php_parallel_output_mutex); + } + return SUCCESS; } #endif