Re: [PHP-DEV] How to embed PHP5 into multi-threaded C app?
Bob Beaty <drbobbeaty <at> gmail.com>
2005-03-01 10:35:43 GMT
OK, I'm with you on this so far, but how do you differentiate
ub_write, log_message, and sapi_error on different threads? It would
seem to me that you'd need to have different functions for each thread
as the calls to ub_write don't include some indication of the thread
that this is being called under.
Then again, maybe it's in the php_embed_module if it's tightly bound
to the thread... For example, if I set the title in the thread-bound
php_embed_module to something specific for each thread then check that
within the call to ub_write() I can see who this 'write' belongs to.
If I'm missing the boat on these function callbacks, or there's an
easier way to capture stdout, stderr, etc. in a ZTS-enabled PHP/Zend
environment, please let me know.
I'm sorry if I seem a bit dense, but I'm trying to figure things out
and design the code before I start writing it.
On Feb 28, 2005, at 11:56 PM, Wez Furlong wrote:
> ZTS enabled PHP has "strong thread affinity".
> Calls into the engine are thread-safe provided that you have
> previously initialized the engine on that thread.
> Note that you should not efree() memory allocated on one thread from
> outside of that thread, on pain of segfault. eg: resources from one
> thread cannot be safely passed on to another thread.