Reentrancy and extensions

php.internals

David Hill (php.net)

23 years ago
Hi, back on reentrancy.... I know that with some of the libraries the extensions depend on are not reentrant (ie. also not thread safe). The imap library cclient comes to mind (unless something has changed recently) and I know gettext caches data in global structures (which would make me wonder). It occurs to me that we already have a list of extenions ( ./EXTENSIONS), what about adding an extra field to the listing? This field would be: ZTS: [unknown|yes|no] and would default to unknown. This would help those of us trying to use Apache2 to choose which extensions can be included based on the extension maintainers view of the safety of the code. Dave

Moriyoshi Koizumi

23 years ago
Sound like a good idea to me. Moriyoshi "David Hill \(php.net\)" <ddhill@php.net> wrote:

Shane Caraveo

23 years ago
David Hill (php.net) wrote:
> Hi, > back on reentrancy.... I know that with some of the libraries the extensions depend on are not reentrant (ie. also not thread safe). The imap library cclient comes to mind (unless something has changed recently) and I know gettext caches data in global structures (which would make me wonder). It occurs to me that we already have a list of extenions ( ./EXTENSIONS), what about adding an extra field to the listing? This field would be: > > ZTS: [unknown|yes|no] > > and would default to unknown. This would help those of us trying to use Apache2 to choose which extensions can be included based on the extension maintainers view of the safety of the code. > > Dave
It should be a runtime or compiletime flag in each extension, not a seperate text file that someone needs to read. Shane

David Hill (php.net)

23 years ago
> It should be a runtime or compiletime flag in each extension, not a > seperate text file that someone needs to read.
In a truely perfect world we would have that compile time flag in the extension definition structure, and then could do a extension specific lock (mutex) before calling functions in extensions that are not thread safe. Doing so would allow php with ZTS to call the dirtiest non-thread safe library without fear. Some might say that doing such a coarse grained lock would trash performance, but at least then you would be less likely to run into concurrency issues. As I mentioned, I would try to use an extension specific mutex instead of a single global mutex as it would (hopefully) reduce stalls if more than one unsafe extension was in use. But that would be a lot more work and would require a non-trivial effort from the guys that know the core followed by a change to all of the extensions. And I know that I am not ready to try a change like that in the core :-) dave