add workaround against shutdown() being called in child task context
This commit is contained in:
parent
f421fcd7e5
commit
cfe6d444a9
|
@ -86,10 +86,12 @@
|
||||||
pcntl_waitpid(-1, $status, WNOHANG);
|
pcntl_waitpid(-1, $status, WNOHANG);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shutdown() {
|
function shutdown($caller_pid) {
|
||||||
if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
|
if ($caller_pid == posix_getpid()) {
|
||||||
_debug("removing lockfile (master)...");
|
if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
|
||||||
unlink(LOCK_DIRECTORY . "/update_daemon.lock");
|
_debug("removing lockfile (master)...");
|
||||||
|
unlink(LOCK_DIRECTORY . "/update_daemon.lock");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@
|
||||||
|
|
||||||
function sigint_handler() {
|
function sigint_handler() {
|
||||||
_debug("[MASTER] SIG_INT received.\n");
|
_debug("[MASTER] SIG_INT received.\n");
|
||||||
shutdown();
|
shutdown(posix_getpid());
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +164,7 @@
|
||||||
if (!$master_handlers_installed) {
|
if (!$master_handlers_installed) {
|
||||||
_debug("[MASTER] installing shutdown handlers");
|
_debug("[MASTER] installing shutdown handlers");
|
||||||
pcntl_signal(SIGINT, 'sigint_handler');
|
pcntl_signal(SIGINT, 'sigint_handler');
|
||||||
register_shutdown_function('shutdown');
|
register_shutdown_function('shutdown', posix_getpid());
|
||||||
$master_handlers_installed = true;
|
$master_handlers_installed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue