Re: Persist context across threads?
| From: | Richard Lynch | Date: | Mon, 21 May 2012 19:15:55 +0000 |
| Subject: | Re: Persist context across threads? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60632@lists.php.net to get a copy of this message | ||
On Mon, May 14, 2012 1:47 pm, David Rueter wrote:
> I am interested in preserving the complete PHP context for a thread
> (globals,
> variables, interpreter, etc.--everything) for later access from a
> different
> thread.
>
> What would be involved in this? It seems like:
>
> 1) Avoid calling ts_free_thread
> 2) Call tsrm_set_interpreter_context from new thread
>
> Is it safe to assume that the context of a terminated thread will not
> be
> destroyed or overwritten as long as ts_free_thread is not called?
I don't really know what I'm talking about, but nobody has answered
yet...
For starters, not all extensions are thread-safe. I would expect that
to mean that anything actively using those extensions saved state in
another thread is a segfault waiting to happen.
For security reasons and sheer plain cussedness, I don't think you're
going want and/or get any resource (mysql connection/result/etc, gd
images, file handles, etc) survive to the next thread. A mysql
connection, for example, is opened with a specific user/pass. Another
thread picking this up could probably abuse that, as I understand it.
Finally, your question begs another question:
Why do you want to do this?
--
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE