Description:
------------
On win32 platform, if I try to startup/shutdown PHP several times during the same thread, after the 2nd startup, the timeout functionality doesn't work, and there is an Windows exception (invalid handle) during the 2nd shutdown.
Reproduce code:
---------------
// 1? startup
php_module_startup(...)
....
php_module_shutdown(..)
..
// 2? startup/shutdown
php_module_startup(...)
// from now the function zend_set_timeout() will not work
Actual result:
--------------
The static variable timeout_thread_initalized declared in the file zend_execute_API.c is not reset to 0 after a shutdown, and so, the next startup will not initialize the timeout thread, and the next shutdown will try to close an invalid handle "CloseHandle(timeout_thread_handle)" inside the function zend_shutdown_timeout_thread(), and I get an exception .
The patch to solve the problem :
--- fix/zend_execute_API.c 2006-04-21 00:49:20.000000000 +0200
+++ zend_execute_API.c 2006-05-23 09:20:38.953125000 +0200
@@ -1339,6 +1339,7 @@
/* Wait for thread termination */
WaitForSingleObject(timeout_thread_handle, 5000);
CloseHandle(timeout_thread_handle);
+ timeout_thread_initialized=0;
}
#endif
But, is it allowed to startup/shutdown several times during the same thread ???
If yes: there is a bug on Win32... If no: there is no bug..

Patches

Pull Requests

History

Usually PHP does startup/shutdown secuence only once per process.
php_module_startup/php_module_shutdown shouldn't be called several times.
BTW: you patch is proper. I committed it into CVS HEAD and PHP_5_2.