# ts_free_thread() frees only temporary in multiple parallel threads

- Thread: https://externals.io/message/51016
- Original archive: https://news-web.php.net/php.internals/51016
- Started by Gary Zipfel on 2010-12-12T15:47:20+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #51016 — Gary Zipfel — 2010-12-12T15:47:20+00:00

URL: https://externals.io/message/51016#51016

(Referring to my posts: #50838 and #50916)

Well although I got the feeling no one cares, I finally found a solution
to my problem!!!

Combining my patch (from post #50916) with the php_embed2 module makes
everything working great in multi-threaded usage. The normal php_embed
module does not seem to be designed for that.

So my final conclusion for the multi-threaded SAPI is the following:
- my patch is needed (to avoid false resource allocation)
- php_embed2 module is needed (instead of php_embed)
- TSRMLS_FETCH() needs to be called at the start of every request
- ts_free_thread() should be called at the end of every request

But I still would like to get any comment about my patch...

---

## #51022 — Benjamin Franke — 2010-12-13T18:31:45+00:00

URL: https://externals.io/message/51016#51022

I referred to the following version of php_embed2:
http double dot slash slash svn.tobin.nl/public/php/embed2/trunk/

This seems to be an official php release especially for multi-threaded
usage but it is not included in official sources.

I just compiled it with my sources and followed the example usage as
written in the examples included within this package.

Greetz



> Hi Gary,
> 
> Which php_embed2 module are you referring to?
> 
> I've made one quite some time ago but never got time to clean it up or even post it to the official source tree as none of the established PHP devs saw any importance in having a thread safe embedded module. So I gave up my efforts and will pick it up shortly for internal usage (as I'm in need of one again).
>  
> kind regards,
> 
> Bas van Beek
> 
>  
> Op 12 dec 2010, om 16:47 heeft Gary Zipfel het volgende geschreven:
> 
> > […]
