You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Brian Pane <bp...@pacbell.net> on 2002/06/22 21:52:31 UTC

worker MPM shutdown

During the worker MPM non-graceful shutdown, the signal_threads()
function attempts to close all open sockets.

I have two major objections to this:

1) It's not necessarily safe to close a socket that another thread
   is using.  Note that apr_socket_close() calls the pool cleanup
   on the pool from which the socket was allocated--bad news if
   one of the active worker threads happens to be, say, registering
   a new cleanup in the same pool at the same time.

2) It appears to be contributing to the fact that non-graceful
   shutdown doesn't work.  Without the socket shutdown loop,
   the child processes shut down promptly.

As I understand it, the motivation for closing the sockets during
shutdown was to try to fix a race condition in which an active
worker thread might be trying to write to a socket at the same
time that the underlying pool was being destroyed (due to the
recursive destruction of APR's global_pool during apr_terminate()).

If so, I think the right solution is to add a way to create
parentless pools that aren't implicitly added as children to
the global pool, so that a worker thread's pool won't disappear
before that thread does.  Is there any specific reason why we're
not doing this already?

Thanks,
--Brian



Installation problems

Posted by Trevor Tregoweth <tr...@txc.net.au>.
Hi All
can anyone give me some idea on what i am doing wrong

trying to install apache 1.3.24 
./configure --add-module=mod_frontpage.c

keep getting the error
mod_frontpage.c:896:6: unterminated comment
mod_frontpage.c:895:27: unterminated #ifdef
make[4]: *** [mod_frontpage.o] Error 1


cheers

John


Re: worker MPM shutdown

Posted by Aaron Bannert <aa...@clove.org>.
On Sun, Jun 23, 2002 at 09:44:03PM -0700, Brian Pane wrote:
> On Sat, 2002-06-22 at 17:01, Ryan Bloom wrote:
> > I believe that the problem is platform specific.  The reason that loop
> > was added, was to allow for graceless shutdown on linux.  On non-linux
> > platforms, killing the main thread kills the whole process, but on linux
> > this doesn't work.  The point of closing the sockets was to force the
> > worker threads to finish ASAP so that the process could die.
> 
> Why not just pthread_kill() all the workers if we're running
> on Linux?  That would be a much more direct way of stopping
> them than closing the sockets.

That could lead to deadlock if one of our threads happens to be inside
of a crossprocess mutex when it is killed. There are solutions to this
problem, but they are not pretty.

-aaron

RE: worker MPM shutdown

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Brian Pane [mailto:bpane@pacbell.net]
> 
> On Sat, 2002-06-22 at 17:01, Ryan Bloom wrote:
> > I believe that the problem is platform specific.  The reason that
loop
> > was added, was to allow for graceless shutdown on linux.  On
non-linux
> > platforms, killing the main thread kills the whole process, but on
linux
> > this doesn't work.  The point of closing the sockets was to force
the
> > worker threads to finish ASAP so that the process could die.
> 
> Why not just pthread_kill() all the workers if we're running
> on Linux?  That would be a much more direct way of stopping
> them than closing the sockets.

Because asynchronous cancellation of threads sucks, and APR doesn't
support it.  Most OSes leak memory when you use pthread_kill().

Ryan



RE: worker MPM shutdown

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Brian Pane [mailto:bpane@pacbell.net]
> 
> On Sat, 2002-06-22 at 17:01, Ryan Bloom wrote:
> > I believe that the problem is platform specific.  The reason that
loop
> > was added, was to allow for graceless shutdown on linux.  On
non-linux
> > platforms, killing the main thread kills the whole process, but on
linux
> > this doesn't work.  The point of closing the sockets was to force
the
> > worker threads to finish ASAP so that the process could die.
> 
> Why not just pthread_kill() all the workers if we're running
> on Linux?  That would be a much more direct way of stopping
> them than closing the sockets.

Because asynchronous cancellation of threads sucks, and APR doesn't
support it.  Most OSes leak memory when you use pthread_kill().

Ryan



RE: worker MPM shutdown

Posted by Brian Pane <bp...@pacbell.net>.
On Sat, 2002-06-22 at 17:01, Ryan Bloom wrote:
> I believe that the problem is platform specific.  The reason that loop
> was added, was to allow for graceless shutdown on linux.  On non-linux
> platforms, killing the main thread kills the whole process, but on linux
> this doesn't work.  The point of closing the sockets was to force the
> worker threads to finish ASAP so that the process could die.

Why not just pthread_kill() all the workers if we're running
on Linux?  That would be a much more direct way of stopping
them than closing the sockets.

--Brian



RE: worker MPM shutdown

Posted by Brian Pane <bp...@pacbell.net>.
On Sat, 2002-06-22 at 17:01, Ryan Bloom wrote:
> I believe that the problem is platform specific.  The reason that loop
> was added, was to allow for graceless shutdown on linux.  On non-linux
> platforms, killing the main thread kills the whole process, but on linux
> this doesn't work.  The point of closing the sockets was to force the
> worker threads to finish ASAP so that the process could die.

Why not just pthread_kill() all the workers if we're running
on Linux?  That would be a much more direct way of stopping
them than closing the sockets.

--Brian



RE: worker MPM shutdown

Posted by Ryan Bloom <rb...@covalent.net>.
I believe that the problem is platform specific.  The reason that loop
was added, was to allow for graceless shutdown on linux.  On non-linux
platforms, killing the main thread kills the whole process, but on linux
this doesn't work.  The point of closing the sockets was to force the
worker threads to finish ASAP so that the process could die.

Ryan

> From: Brian Pane [mailto:bpane@pacbell.net]
> 
> During the worker MPM non-graceful shutdown, the signal_threads()
> function attempts to close all open sockets.
> 
> I have two major objections to this:
> 
> 1) It's not necessarily safe to close a socket that another thread
>    is using.  Note that apr_socket_close() calls the pool cleanup
>    on the pool from which the socket was allocated--bad news if
>    one of the active worker threads happens to be, say, registering
>    a new cleanup in the same pool at the same time.
> 
> 2) It appears to be contributing to the fact that non-graceful
>    shutdown doesn't work.  Without the socket shutdown loop,
>    the child processes shut down promptly.
> 
> As I understand it, the motivation for closing the sockets during
> shutdown was to try to fix a race condition in which an active
> worker thread might be trying to write to a socket at the same
> time that the underlying pool was being destroyed (due to the
> recursive destruction of APR's global_pool during apr_terminate()).
> 
> If so, I think the right solution is to add a way to create
> parentless pools that aren't implicitly added as children to
> the global pool, so that a worker thread's pool won't disappear
> before that thread does.  Is there any specific reason why we're
> not doing this already?
> 
> Thanks,
> --Brian
> 



RE: worker MPM shutdown

Posted by Ryan Bloom <rb...@covalent.net>.
I believe that the problem is platform specific.  The reason that loop
was added, was to allow for graceless shutdown on linux.  On non-linux
platforms, killing the main thread kills the whole process, but on linux
this doesn't work.  The point of closing the sockets was to force the
worker threads to finish ASAP so that the process could die.

Ryan

> From: Brian Pane [mailto:bpane@pacbell.net]
> 
> During the worker MPM non-graceful shutdown, the signal_threads()
> function attempts to close all open sockets.
> 
> I have two major objections to this:
> 
> 1) It's not necessarily safe to close a socket that another thread
>    is using.  Note that apr_socket_close() calls the pool cleanup
>    on the pool from which the socket was allocated--bad news if
>    one of the active worker threads happens to be, say, registering
>    a new cleanup in the same pool at the same time.
> 
> 2) It appears to be contributing to the fact that non-graceful
>    shutdown doesn't work.  Without the socket shutdown loop,
>    the child processes shut down promptly.
> 
> As I understand it, the motivation for closing the sockets during
> shutdown was to try to fix a race condition in which an active
> worker thread might be trying to write to a socket at the same
> time that the underlying pool was being destroyed (due to the
> recursive destruction of APR's global_pool during apr_terminate()).
> 
> If so, I think the right solution is to add a way to create
> parentless pools that aren't implicitly added as children to
> the global pool, so that a worker thread's pool won't disappear
> before that thread does.  Is there any specific reason why we're
> not doing this already?
> 
> Thanks,
> --Brian
>