On Mon, Mar 22, 2010 at 4:55 PM, troels knak-nielsen <troel...@gmail.com> wrote: > On Mon, Mar 22, 2010 at 4:41 PM, Herman Radtke <hermanrad...@gmail.com> wrote: >>> What do you mean by "no option"? Otherwise yes, that's what it does. >> Using sleep there is not a good practice. Since the custom error >> handler is triggered, there is no need for the sleep call anyways. > > So control isn't returned to the C-code before the php error handler > finishes. Is that it?
Just checked, and you're right about this. I've made a new patch, which addresses this. Again, I have no idea about whether I'm violating code style (Should zend_timeout_softswitch be declared or named differently?), so comments on that please? New patch attached - disregard the previous one. -- troels
--- ./Zend/zend_execute_API.c.orig 2010-03-22 15:33:17.000000000 +0100 +++ ./Zend/zend_execute_API.c 2010-03-22 18:45:08.000000000 +0100 @@ -1300,18 +1300,26 @@ } /* }}} */ +static int zend_timeout_softswitch = 0; + ZEND_API void zend_timeout(int dummy) /* {{{ */ { - TSRMLS_FETCH(); - - if (zend_on_timeout) { - zend_on_timeout(EG(timeout_seconds) TSRMLS_CC); + if (zend_timeout_softswitch == 0) { + zend_timeout_softswitch = 1; + zend_unset_timeout(TSRMLS_C); + zend_set_timeout(1, 1); + zend_error(E_WARNING, "Maximum execution time of %d second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s"); + } else { + TSRMLS_FETCH(); + + if (zend_on_timeout) { + zend_on_timeout(EG(timeout_seconds) TSRMLS_CC); + } + + zend_error(E_ERROR, "Maximum execution time of %d second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s"); } - - zend_error(E_ERROR, "Maximum execution time of %d second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s"); } -/* }}} */ - + /* }}} */ #ifdef ZEND_WIN32 static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* {{{ */ {
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php