diff options
author | Rasmus Lerdorf <rasmus@php.net> | 2008-03-18 21:42:50 +0000 |
---|---|---|
committer | Rasmus Lerdorf <rasmus@php.net> | 2008-03-18 21:42:50 +0000 |
commit | 6c158374ba57792b0e283053e0a22944a42ef25b (patch) | |
tree | 2a45ed6760070254817be81a96ae26f3ed491b86 /Zend/zend_execute_API.c | |
parent | 10afe5d96bc3d562958e905102de1db44188ac2b (diff) | |
download | php-git-6c158374ba57792b0e283053e0a22944a42ef25b.tar.gz |
exit_on_timeout patch
After the sigsetjmp change, this is patch #2 in an effort to get some
sanity restored to signal handling in PHP.
This patch does two things. First, it makes it possible to reset the
timeout without resetting the signal handlers. This is important for
cases where an extension may have deferred signals in its MINIT in order
to implement critical sections. It also lays the groundwork for cleaning
up our signal handling and perhaps eventually implementing our own
signal deferring mechanism so we can have true critical sections.
The second thing this does is to make it possible to terminate the current
child process (only for Apache1 at the moment) on a timeout. There are
a number of extensions that are unhappy about being longjmp'ed out of
and when this happens on a timeout they are left in an inconsistent state.
By turning on exit_on_timeout you can now force the process to terminate
on a timeout which will clean up any hanging locks and/or memory left
hanging after the longjmp.
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 34b9957bb7..59f3e61400 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1527,7 +1527,7 @@ void zend_shutdown_timeout_thread(void) /* {{{ */ #define SIGPROF 27 #endif -void zend_set_timeout(long seconds) /* {{{ */ +void zend_set_timeout(long seconds, int reset_signals) /* {{{ */ { TSRMLS_FETCH(); @@ -1554,16 +1554,22 @@ void zend_set_timeout(long seconds) /* {{{ */ # ifdef __CYGWIN__ setitimer(ITIMER_REAL, &t_r, NULL); - signal(SIGALRM, zend_timeout); - sigemptyset(&sigset); - sigaddset(&sigset, SIGALRM); + if(reset_signals) { + signal(SIGALRM, zend_timeout); + sigemptyset(&sigset); + sigaddset(&sigset, SIGALRM); + } # else setitimer(ITIMER_PROF, &t_r, NULL); - signal(SIGPROF, zend_timeout); - sigemptyset(&sigset); - sigaddset(&sigset, SIGPROF); + if(reset_signals) { + signal(SIGPROF, zend_timeout); + sigemptyset(&sigset); + sigaddset(&sigset, SIGPROF); + } # endif - sigprocmask(SIG_UNBLOCK, &sigset, NULL); + if(reset_signals) { + sigprocmask(SIG_UNBLOCK, &sigset, NULL); + } } # endif #endif |