+---------- On Oct 14, Andrew Piskorski said:
> I am kind of confused, as a lot of the code in AOLserver DOES use
> Ns_MasterLock like that, but some of it does not, and nothing in the
> docs suggest that you need to or should.
>
> E.g., aolserver/nsd/adp.c and aolserver/nsd/dbinit.c both use
> Ns_MasterLock.  aolserver/thread/test.c seems to sometimes use it
> sometimes not.  nscache/tclcache.c definitely does not use it.

tclcache.c should use it.  That it doesn't use it is a bug, but it's
unlikely to be triggered.

Any time you call Ns_TlsAlloc, you should ensure that no other thread
can be calling Ns_TlsAlloc on the same Ns_Tls object at the same time.
You can do that with Ns_MasterLock/Ns_MasterUnlock.

My normal usage (and therefore ArsDigita's) was to create all caches at
server startup time, when only a single thread is running. There's no
possibility of a race condition if you only call "ns_cache create" at
startup time (or if you never create thread-private caches).

Reply via email to