httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject Re: Clean shutdown on Windows
Date Tue, 26 Oct 2010 15:21:36 GMT
On Mon, Oct 25, 2010 at 10:30 AM, Gabriel Petrovay
<gabipetrovay@gmail.com> wrote:
> Hi,
>
> Maybe this gives you some hints. I have looked a little in the code of
> mod_fcgi. In fcgid_pm_main.c (361) you have:
>
> /* Kill gracefully */
> for (i = 0; i < proctable_get_table_size(); i++) {
>    if (proc_table[i].proc_pool)
>        proc_kill_gracefully(&proc_table[i], main_server);
> }
> apr_sleep(apr_time_from_sec(1));
>
> /* Kill with SIGKILL if it doesn't work */
> for (i = 0; i < proctable_get_table_size(); i++) {
>    if (proc_table[i].proc_pool) {
>        if (apr_proc_wait(&(proc_table[i].proc_id), &exitcode, &exitwhy,
>                          APR_NOWAIT) != APR_CHILD_NOTDONE) {
>            proc_table[i].diewhy = FCGID_DIE_SHUTDOWN;
>            proc_print_exit_info(&proc_table[i], exitcode, exitwhy,
>                                 main_server);
>            apr_pool_destroy(proc_table[i].proc_pool);
>            proc_table[i].proc_pool = NULL;
>        }
>        else
>            proc_kill_force(&proc_table[i], main_server);
>    }
> }
>
> ---------------------------------
>
> You can see that mod_fcgi tries to gracefully kill the child processes
> (proc_kill_gracefully).
>
> Than it waits 1 second. (probably hoping that the process finishes,
> case in which the assumption is wrong; assume that we need 2 seconds
> to shut-down).
>
> Than it starts to kill all the still running processes (/* Kill with
> SIGKILL if it doesn't work */). Since my process is not finished, it
> returns in line 371 APR_CHILD_NOTDONE (70006) so proc_kill_force() is
> called in line 380.
>
> So that is why my process is killed at random times during shutdown.
>
>
> Is this a bug? or am I missing something?

IMO this should work in a similar manner to the
ap_reclaim_child_processes functions used by Unix MPMs:

kill-gracefully
wait
kill-gracefully
wait
kill-gracefully
wait
kill-forcefully (this starts at about 9 seconds)
wait
giveup

though mod_fcgid doesn't necessarily need so many iterations or as
large a delay.

I'll plan to code up a patch for this in the next day or so.

Mime
View raw message