httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Hyde <bh...@pobox.com>
Subject Re: Pools not adequeately protected by mutexes?
Date Wed, 28 Apr 1999 21:44:21 GMT
Manoj Kasichainula <manojk@raleigh.ibm.com> writes:

> While poking around the pool code, I noticed this (essentially
> unchanged between 1.3 and the hybrid server)
> 
> API_EXPORT(void) ap_register_cleanup(blah blah)
> {
>     struct cleanup *c = (struct cleanup *) ap_palloc();
>     c->data = data;
>     c->plain_cleanup = plain_cleanup;
>     c->child_cleanup = child_cleanup;
>     c->next = p->cleanups;
> ------>
>     p->cleanups = c;
> }
> 
> However, if we get a context switch at the arrow, and another thread
> is running ap_register_cleanup, couldn't we lose a cleanup? I spotted
> a couple of other cases like this, but I'm really not at one with the
> pool code yet.
> 
> Don't these need to be protected by mutexes?
> 
> As an aside, is there any macro accessible in pthreads, Windows, etc.
> that tells you what operations can be assumed to be atomic? On a
> load-store architecture, even a character assignment could potentially
> be unsafe.

No no no!  The pool API is designed with the presumption that operations
on a single pool are done only by a single thread.  If two threads wish
to share a pool they must mux their accesses.

There was a long discussion between Dean and I, last October maybe, on
this topic in new-httpd.  He straighted me out and like any reformed sinner
I'm now a true beliver.  This is the right design.

Don't forget that 1.3 is multithread in NT and we visited a lot of
these issues then.

   - ben

Mime
View raw message