summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJille Timmermans <jille@quis.cx>2014-06-11 17:34:34 +0200
committerJulien Pauli <jpauli@php.net>2014-12-12 18:16:12 +0100
commit9beb3763dbafb5421f4a263510bab73f8d7b80c2 (patch)
treecc8df304d88ca844db8ac465b1f5db58b0e1a5a6
parentd43d0663af9d7f11985fa6994f785b2dd5cb0faa (diff)
downloadphp-git-9beb3763dbafb5421f4a263510bab73f8d7b80c2.tar.gz
pcntl_signal_dispatch: Speed up by preventing system calls when unnecessary
-rw-r--r--ext/pcntl/pcntl.c7
-rw-r--r--ext/pcntl/php_pcntl.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 3c9eb67629..1ee8ba799f 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -1225,6 +1225,7 @@ static void pcntl_signal_handler(int signo)
PCNTL_G(head) = psig;
}
PCNTL_G(tail) = psig;
+ PCNTL_G(pending_signals) = 1;
}
void pcntl_signal_dispatch()
@@ -1234,6 +1235,10 @@ void pcntl_signal_dispatch()
sigset_t mask;
sigset_t old_mask;
TSRMLS_FETCH();
+
+ if(!PCNTL_G(pending_signals)) {
+ return;
+ }
/* Mask all signals */
sigfillset(&mask);
@@ -1273,6 +1278,8 @@ void pcntl_signal_dispatch()
queue = next;
}
+ PCNTL_G(pending_signals) = 0;
+
/* Re-enable queue */
PCNTL_G(processing_signal_queue) = 0;
diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h
index caafc10d19..44e91166ae 100644
--- a/ext/pcntl/php_pcntl.h
+++ b/ext/pcntl/php_pcntl.h
@@ -69,6 +69,7 @@ ZEND_BEGIN_MODULE_GLOBALS(pcntl)
int processing_signal_queue;
struct php_pcntl_pending_signal *head, *tail, *spares;
int last_error;
+ volatile char pending_signals;
ZEND_END_MODULE_GLOBALS(pcntl)
#ifdef ZTS