Re: TSRM coverage question

From: Date: Wed, 19 Sep 2001 09:41:31 +0000
Subject: Re: TSRM coverage question
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-66216@lists.php.net to get a copy of this message
> On Tue, 18 Sep 2001, "lo-tek" <@pb1.pair.com cshmoove wrote: > > > suppose i have a function which returns a pointer to a variable in thread > > local storage > > > > foo_t *get_global_foo() > > { > > TSRMLS_FETCH(); > > return (foo_t *)BAR_G(foo); > > } > > > > void fubar() > > { > > foo_t *foo = get_global_foo(); > > bar( foo ); /* possible multi-thread access */ > > } > > > > is fubar then thread safe, or is TSRMLS_FETCH() (or TSRMLS_C etc) needed in > > each function needing serialized access to TLS data ? > > > > Well, your just tossing around pointers (your returning a pointer to > an address in the global structure which is assigned to foo, which > you then pass to bar). So thread safety should *not* be affected. But AFAIK TSRM* do NOT force serialized execution of functions, they just make sure that each uses a different set of php-globals. So if bar( ) is not thread-safe, the whole function still won't be thread safe, no matter whether you use TSRM. It simply depends on the bar( ) function. I don't know what the solution should be, of course it will be some kind of locking, but I don't know what would be the best solution. --Jeroen

« previous php.dev (#66216) next »