Skip to content

Commit 3769aee

Browse files
author
Julien Pauli
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: pcntl_signal_dispatch: Speed up by preventing system calls when unnecessary
2 parents 238529f + 9beb376 commit 3769aee

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

ext/pcntl/pcntl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,7 @@ static void pcntl_signal_handler(int signo)
12251225
PCNTL_G(head) = psig;
12261226
}
12271227
PCNTL_G(tail) = psig;
1228+
PCNTL_G(pending_signals) = 1;
12281229
}
12291230

12301231
void pcntl_signal_dispatch()
@@ -1234,6 +1235,10 @@ void pcntl_signal_dispatch()
12341235
sigset_t mask;
12351236
sigset_t old_mask;
12361237
TSRMLS_FETCH();
1238+
1239+
if(!PCNTL_G(pending_signals)) {
1240+
return;
1241+
}
12371242

12381243
/* Mask all signals */
12391244
sigfillset(&mask);
@@ -1273,6 +1278,8 @@ void pcntl_signal_dispatch()
12731278
queue = next;
12741279
}
12751280

1281+
PCNTL_G(pending_signals) = 0;
1282+
12761283
/* Re-enable queue */
12771284
PCNTL_G(processing_signal_queue) = 0;
12781285

ext/pcntl/php_pcntl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ZEND_BEGIN_MODULE_GLOBALS(pcntl)
6969
int processing_signal_queue;
7070
struct php_pcntl_pending_signal *head, *tail, *spares;
7171
int last_error;
72+
volatile char pending_signals;
7273
ZEND_END_MODULE_GLOBALS(pcntl)
7374

7475
#ifdef ZTS

0 commit comments

Comments
 (0)