httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Petrovay <gabipetro...@gmail.com>
Subject Re: Clean shutdown on Windows
Date Mon, 25 Oct 2010 14:30:41 GMT
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?


Thanks!

Gabriel


On Mon, Oct 25, 2010 at 12:17 PM, Gabriel Petrovay
<gabipetrovay@gmail.com> wrote:
> Hi,
>
> I am using:
> Server version: Apache/2.2.16 (Win32)
> Server built:   Jul 30 2010 16:15:37
>
> and also:
> mod_fcgid (2.3.5)
>
> I start Apache form console:
> httpd.exe -f my_httpd_conf_file.conf
>
> fcgid starts as expectedly my_fcgi.exe (written in C++) which performs
> the logic of my requests. For this I use the following .htaccess line:
> RewriteRule ^(.*)$ /fcgi-bin/sausa_fcgi.exe [QSA,L]
>
> The problem is that at shutdown, some more steps have to be performed
> by and my_fcgi.exe. When I press Ctrl-C in cmd where Apache was
> started, Apache gets it and simply kills my my_fcgi.exe that was
> started. my_fcgi.exe also catches CTRL-C but at a random time during
> it's shutdown logic, it's killed by Apache.
>
> Is there a way to shutdown Apache properly in order to have a clean
> shutdown or an uninitialize of the underlying processes?
> Or, is there un-initialize handlers that modules like mod_fcgid have
> such that I can properly showdown my-fcgi.exe?
>
> Apache has to wait somehow until the Apache modules (mod_fcgi in this
> case) are un-initialized. Probably I don't implement something in the
> un-initialize process. Any hint are very appreciated.
>
> Thanks!
>
>
> PS: I was instructed to post this message here after I posted it to
> the users mailing list.
>
> --
> MSc Gabriel Petrovay
> Mobile: +41(0)787978034
> www.28msec.com
>



-- 
MSc Gabriel Petrovay
Mobile: +41(0)787978034
www.28msec.com

Mime
View raw message