svn: /php/php-src/branches/PHP_5_2/ ext/pcntl/pcntl.c ext/pcntl/php_signal.c ext/pcntl/php_signal.h tests/security/open_basedir_parse_ini_file.phpt
| From: | Arnaud Le Blanc | Date: | Mon, 14 Feb 2011 17:06:31 +0000 |
| Subject: | svn: /php/php-src/branches/PHP_5_2/ ext/pcntl/pcntl.c ext/pcntl/php_signal.c ext/pcntl/php_signal.h tests/security/open_basedir_parse_ini_file.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64542@lists.php.net to get a copy of this message | ||
lbarnaud Mon, 14 Feb 2011 17:06:31 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308329
Log:
MFH fixed bug #52784 (Race condition when handling many
concurrent signals)
Bug: http://bugs.php.net/52784 (Closed) Race condition when
handling many concurrent signals
Changed paths:
_U php/php-src/branches/PHP_5_2/
_U php/php-src/branches/PHP_5_2/ext/ldap/
U php/php-src/branches/PHP_5_2/ext/pcntl/pcntl.c
U php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.c
U php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.h
_U php/php-src/branches/PHP_5_2/ext/tidy/tests/
_U php/php-src/branches/PHP_5_2/tests/security/open_basedir_parse_ini_file.phpt
Property changes on: php/php-src/branches/PHP_5_2
___________________________________________________________________
Modified: svn:mergeinfo
- /php/php-src/branches/PHP_5_3:284120,288260,288273
/php/php-src/trunk:284726
+ /php/php-src/branches/PHP_5_3:284120,288260,288273
/php/php-src/trunk:284726,305018-305019
Property changes on: php/php-src/branches/PHP_5_2/ext/ldap
___________________________________________________________________
Modified: svn:mergeinfo
- /php/php-src/branches/PHP_5_3/ext/ldap:284120
/php/php-src/trunk/ext/ldap:282758,284726
+ /php/php-src/branches/PHP_5_3/ext/ldap:284120
/php/php-src/trunk/ext/ldap:282758,284726,305018-305019
Modified: php/php-src/branches/PHP_5_2/ext/pcntl/pcntl.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pcntl/pcntl.c 2011-02-14 15:34:04 UTC (rev 308328)
+++ php/php-src/branches/PHP_5_2/ext/pcntl/pcntl.c 2011-02-14 17:06:31 UTC (rev 308329)
@@ -567,7 +567,7 @@
zend_hash_index_update(&PCNTL_G(php_signal_table), signo, (void **) &handle, sizeof(zval
*), (void **) &dest_handle);
if (dest_handle) zval_add_ref(dest_handle);
- if (php_signal(signo, pcntl_signal_handler, (int) restart_syscalls) == SIG_ERR) {
+ if (php_signal4(signo, pcntl_signal_handler, (int) restart_syscalls, 1) == SIG_ERR) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error assigning signal");
RETURN_FALSE;
}
@@ -682,11 +682,19 @@
{
zval *param, **handle, *retval;
struct php_pcntl_pending_signal *queue, *next;
+ sigset_t mask;
+ sigset_t old_mask;
TSRMLS_FETCH();
+
+ /* Mask all signals */
+ sigfillset(&mask);
+ sigprocmask(SIG_BLOCK, &mask, &old_mask);
/* Bail if the queue is empty or if we are already playing the queue*/
- if (! PCNTL_G(head) || PCNTL_G(processing_signal_queue))
+ if (! PCNTL_G(head) || PCNTL_G(processing_signal_queue)) {
+ sigprocmask(SIG_SETMASK, &old_mask, NULL);
return;
+ }
/* Prevent reentrant handler calls */
PCNTL_G(processing_signal_queue) = 1;
@@ -718,6 +726,9 @@
/* Re-enable queue */
PCNTL_G(processing_signal_queue) = 0;
+
+ /* return signal mask to previous state */
+ sigprocmask(SIG_SETMASK, &old_mask, NULL);
}
Modified: php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.c 2011-02-14 15:34:04 UTC (rev 308328)
+++ php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.c 2011-02-14 17:06:31 UTC (rev 308329)
@@ -22,12 +22,15 @@
/* php_signal using sigaction is derrived from Advanced Programing
* in the Unix Environment by W. Richard Stevens p 298. */
-Sigfunc *php_signal(int signo, Sigfunc *func, int restart)
+Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all)
{
-
struct sigaction act,oact;
act.sa_handler = func;
- sigemptyset(&act.sa_mask);
+ if (mask_all) {
+ sigfillset(&act.sa_mask);
+ } else {
+ sigemptyset(&act.sa_mask);
+ }
act.sa_flags = 0;
if (signo == SIGALRM || (! restart)) {
#ifdef SA_INTERRUPT
@@ -44,3 +47,7 @@
return oact.sa_handler;
}
+Sigfunc *php_signal(int signo, Sigfunc *func, int restart)
+{
+ return php_signal4(signo, func, restart, 0);
+}
Modified: php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.h
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.h 2011-02-14 15:34:04 UTC (rev 308328)
+++ php/php-src/branches/PHP_5_2/ext/pcntl/php_signal.h 2011-02-14 17:06:31 UTC (rev 308329)
@@ -24,5 +24,6 @@
typedef void Sigfunc(int);
Sigfunc *php_signal(int signo, Sigfunc *func, int restart);
+Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all);
#endif
Property changes on: php/php-src/branches/PHP_5_2/ext/tidy/tests
___________________________________________________________________
Modified: svn:mergeinfo
- /php/php-src/branches/PHP_5_3/ext/tidy/tests:284120
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941
+ /php/php-src/branches/PHP_5_3/ext/tidy/tests:284120
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941,305018-305019
Property changes on: php/php-src/branches/PHP_5_2/tests/security/open_basedir_parse_ini_file.phpt
___________________________________________________________________
Modified: svn:mergeinfo
- /php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:284120
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951
+ /php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:284120
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951,305018-305019