httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@covalent.net>
Subject Re: Terminiting threads in a process RE: [PATCH] Problems with MPM threaded
Date Sat, 14 Jul 2001 20:29:35 GMT
On Sat, 14 Jul 2001, Justin Erenkrantz wrote:

> On Sat, Jul 14, 2001 at 09:13:08PM +0200, Sander Striker wrote:
> > The way I see it, each process has a single pool instance as the parent
> > for all the threads. Resetting or destroying that pool should effectively
> > kill all threads. What am I missing?
>
> As I see it, the problem is:
>
> [ Platforms with SAFE_ACCEPT == APR_SUCCESS rather than the lock don't
>   apply here. ]
>
> All threads are stuck in the accept mutex except for one.  It reads the
> POD.  And, it is time to die.  It sets workers_may_exit to 1.  It then
> releases the accept mutex and exits.  Another *child process* acquires
> the accept mutex.  Depending upon how many child processes you have, it
> may take a while for all of the threads in the doomed child process to
> acquire the mutex, wake up, check workers_may_exit, release the mutex,
> and then exit.  Only when all of the threads in the doomed child process
> are exited does any cleanup occur.

This is why the original code, in apache-apr, written by Manoj back at IBM
used two mutexes.  The first was cross-process, the second was
cross-threads.  It allowed us to handle this much cleaner.  I didn't
realize this had been removed.

> And, you can't kick the thread out of the mutex acquire (pthread_cancel
> or similar strategies don't cancel a mutex operation), so you are
> screwed.  And, destroying its parent pool does *NOT* destroy the
> thread.  Look at the code again.  The only person that can call
> pthread_exit() is the actual thread itself.  You can't call
> pthread_exit on behalf of another thread (i.e. from the thread that
> knows it is doomed or a cleanup thread).  It just doesn't work like
> that.
>
> I just don't agree with Ryan's assessment here.  But, it's possible
> I'm missing some major piece of code.  -- justin

What you are missing is the history.  All of the problems that we are
trying to solve were solved already in the original code.  These problem
are solved most easily by using two mutexes, one for keeping only one
process in the inner loop, and the inner one for the threads in the
process.  Then, when you are killing a process, you can easily wake up all
the threads in the process that are sitting on a lock.

Ryan


_____________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
Covalent Technologies			rbb@covalent.net
-----------------------------------------------------------------------------






Mime
View raw message