I am currently developing a kind of application server based on PHP
I use modifications I made on SAPI embed/.
I use threads massively.
In my application design, every thread can load different PHP modules. In
practise, modules are loaded just before php_request_startup() and they are
unloaded after php_request_shutdown()
The problem I face is that I randomly receive PHP warnings :
<b>Warning</b>: Module 'X7V3' already loaded in <b>Unknown</b> on line
<b>Warning</b>: Function registration failed - duplicate name -
XXXXXXXXXXXXXXXXXX in <b>Unknown</b> on line <b>0</b><br />
<b>Warning</b>: X7V3: Unable to register functions, unable to load in
<b>Unknown</b> on line <b>0</b><br /
I looked at Zend/zend_API.c and I realized that 2 variables, "module_count"
and "module_registry", are not thread safe and that there is a comment
recomending mutex use for these 2 variables.
I had asked for a Feature/Change request on bugs.php.net (#40668) but it has
been closed :s
Then I learnt (thank you Tony) that dl() function is deactivated in ZTS
mode and I also learnt from Tony that this kind of problem was not a
I think it is important to settle this problem at least for IIS and Apache
At last, I would like to share my view on ZTS vs mutex use :
pros : uses slightly less memory
cons : does not give possibility to create module spaces by thread - uses
more processor resource (as there is a mutualized lock for various threads)
pros : possibility to create module spaces - less processor
cons : slight impact on memory
This is why I propose to use a ZTS resource instead of mutex to make
"module_registry" thread safe.
The use of ZTS resources will give a thread the ability to have its own
In both cases (mutex or ZTS resource), we will be able to reactivate the
dl() function in ZTS mode.
I propose to develop the ZTS version resource. Or shall I let you do it ?