Hi Ruslan, > -----Original Message----- > From: Ruslan Osmanov [mailto:rrosma...@gmail.com] > Sent: Wednesday, November 25, 2015 5:47 PM > To: PECL Developers <pecl-dev@lists.php.net> > Subject: [PECL-DEV] Re: How do I save TSRMLS_CACHE for a new thread in > PHP7? > > What do I do now? > > On Sun, 22 Nov 2015 11:42:45 +0500 > Ruslan Osmanov <rrosma...@gmail.com> wrote: > > > Hi, > > > > suppose we are using Zend API in a new thread (created by extension). > > The problem that Zend API context(ZEND_TSRMLS_CACHE) is a thread-local > > variable. > > > > I'm looking for a way to pass ZEND_TSRMLS_CACHE to my thread. I'm used > > to use TSRMLS_FETCH_FROM_CTX(thread_data) and > > TSRMLS_SET_CTX(thread_data) in previous PHP versions. Now, in PHP7 > > they are not working - _tsrm_ls_cache is equal to zero within thread > > function: > > > > (gdb) print _tsrm_ls_cache > > void* 0x0 > > > > Well, as I've mentioned, I'm aware of that ZEND_TSRMLS_CACHE is a > > thread-local variable. Probably, the OS kernel took care of keeping > > thread-local data thread-local, and that's why I can't access the > > "saved" thread context. > > > > But then how am I supposed to use Zend API working with ZTS in my own > > thread? > > I'm not quite sure what exactly you're doing.
If you need some data from another thread, you can pass it to your new thread callback. It is correct, ZEND_TSRMLS_CACHE is thread local and cannot be passed to another thread. But the data can be passed, especially for the read only cases. And you also should ensure that PHP request doesn't end while your thread is running. Regards Anatol -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php