Skip to content

Commit 8ff4abb

Browse files
author
Julien Pauli
committed
Merge branch 'PHP-5.6'
* PHP-5.6: pcntl_signal_dispatch: Speed up by preventing system calls when unnecessary
2 parents 0adfa03 + 3769aee commit 8ff4abb

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
@@ -1212,6 +1212,7 @@ static void pcntl_signal_handler(int signo)
12121212
PCNTL_G(head) = psig;
12131213
}
12141214
PCNTL_G(tail) = psig;
1215+
PCNTL_G(pending_signals) = 1;
12151216
}
12161217

12171218
void pcntl_signal_dispatch()
@@ -1221,6 +1222,10 @@ void pcntl_signal_dispatch()
12211222
sigset_t mask;
12221223
sigset_t old_mask;
12231224
TSRMLS_FETCH();
1225+
1226+
if(!PCNTL_G(pending_signals)) {
1227+
return;
1228+
}
12241229

12251230
/* Mask all signals */
12261231
sigfillset(&mask);
@@ -1258,6 +1263,8 @@ void pcntl_signal_dispatch()
12581263
queue = next;
12591264
}
12601265

1266+
PCNTL_G(pending_signals) = 0;
1267+
12611268
/* Re-enable queue */
12621269
PCNTL_G(processing_signal_queue) = 0;
12631270

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)