diff options
author | Dmitry Stogov <dmitry@zend.com> | 2016-06-23 15:01:23 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2016-06-23 15:01:23 +0300 |
commit | d0460d8f6be04fc9493fc7db99d29168b46f3e72 (patch) | |
tree | 3951381c23545f2ef03d4ca5faf3f50402ffc9f3 /Zend/zend_execute_API.c | |
parent | adc95c511495f00cd1a90feff5fff7968e38fc4a (diff) | |
download | php-git-d0460d8f6be04fc9493fc7db99d29168b46f3e72.tar.gz |
Turn safe timeout handling into general interrupt handling ability.
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index d292de19e4..4c7946f690 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -172,6 +172,7 @@ void init_executor(void) /* {{{ */ zend_objects_store_init(&EG(objects_store), 1024); EG(full_tables_cleanup) = 0; + EG(vm_interrupt) = 0; EG(timed_out) = 0; EG(exception) = NULL; @@ -1225,6 +1226,7 @@ static void zend_timeout_handler(int dummy) /* {{{ */ } EG(timed_out) = 1; + EG(vm_interrupt) = 1; #ifndef ZTS if (EG(hard_timeout) > 0) { @@ -1239,7 +1241,7 @@ static void zend_timeout_handler(int dummy) /* {{{ */ #ifdef ZEND_WIN32 VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out) { - zend_bool *php_timed_out; + zend_executor_globals *eg; /* The doc states it'll be always true, however it theoretically could be FALSE when the thread was signaled. */ @@ -1247,8 +1249,9 @@ VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out) return; } - php_timed_out = (zend_bool *)arg; - *php_timed_out = 1; + eg = (zend_bool *)arg; + eg->timed_out = 1; + eg->vm_interrupt = 1; } #endif @@ -1259,6 +1262,7 @@ VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out) static void zend_set_timeout_ex(zend_long seconds, int reset_signals) /* {{{ */ { + zend_execute_data *eg; #ifdef ZEND_WIN32 if(!seconds) { @@ -1278,7 +1282,14 @@ static void zend_set_timeout_ex(zend_long seconds, int reset_signals) /* {{{ */ } /* XXX passing NULL means the default timer queue provided by the system is used */ - if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)&EG(timed_out), seconds*1000, 0, WT_EXECUTEONLYONCE)) { +#ifndef ZTS + eg = &execute_data; +#elif defined(ZEND_ENABLE_STATIC_TSRMLS_CACHE) + eg = TSRMG_BULK_STATIC(executor_globals_id, zend_executor_globals *) +#else + eg = TSRMG_BULK(executor_globals_id, zend_executor_globals *) +#endif + if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)eg, seconds*1000, 0, WT_EXECUTEONLYONCE)) { tq_timer = NULL; zend_error_noreturn(E_ERROR, "Could not queue new timer"); return; |