]> git.wh0rd.org Git - tt-rss.git/commitdiff
add workaround against shutdown() being called in child task context
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 25 Feb 2013 17:59:26 +0000 (21:59 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 25 Feb 2013 17:59:26 +0000 (21:59 +0400)
update_daemon2.php

index b2b2cc982cd8f14da6361efd590688d42567ac42..4b6a43999167a44b04be89aa4f3dd4f23f728938 100755 (executable)
                pcntl_waitpid(-1, $status, WNOHANG);
        }
 
-       function shutdown() {
-               if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
-                       _debug("removing lockfile (master)...");
-                       unlink(LOCK_DIRECTORY . "/update_daemon.lock");
+       function shutdown($caller_pid) {
+               if ($caller_pid == posix_getpid()) {
+                       if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
+                               _debug("removing lockfile (master)...");
+                               unlink(LOCK_DIRECTORY . "/update_daemon.lock");
+                       }
                }
        }
 
 
        function sigint_handler() {
                _debug("[MASTER] SIG_INT received.\n");
-               shutdown();
+               shutdown(posix_getpid());
                die;
        }
 
                                        if (!$master_handlers_installed) {
                                                _debug("[MASTER] installing shutdown handlers");
                                                pcntl_signal(SIGINT, 'sigint_handler');
-                                               register_shutdown_function('shutdown');
+                                               register_shutdown_function('shutdown', posix_getpid());
                                                $master_handlers_installed = true;
                                        }