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 16:26:16 GMT
On Tue, Oct 26, 2010 at 11:52 AM, Gabriel Petrovay
<gabipetrovay@gmail.com> wrote:
> Thanks for the answer!
>
> Or, is a solution like the one we already wrote good (see below or
> attached)? At least it does the job for us. Your solution (if
> implemented like you said) will wait always 4 times.

no, that was a description of what the MPMs use on Unix, and as stated
I don't think fcgid needs as many iterations or as long a sleep; some
key characteristics missing from that description:

* it processes the entire table between sleeps instead of focusing on
one before moving to the next
* it stops waiting when there is nothing more to wait for

>          In the one below,
> it waits only as long as the process is still running (for maximum 30
> secs). And maybe you want to define this timeout in the configuration
> file.

Since the MPMs have gotten away with this being unconfigurable for so
many years (back to httpd 1.3 or earlier), we should be able to avoid
configuration for mod_fcgid as well.

>
> Does this make sense?

>
>
> Add instead of lines 379-380 the following lines:
>
> // original code //////////////////////////////////////////////////////////////
> //            else
> //                proc_kill_force(&proc_table[i], main_server);
> // new code ///////////////////////////////////////////////////////////////////
>            else {
>                // don't kill the process immediately, wait 30 sec
>                // every 0.5s test if the process has finished
>                int seconds = 30; // get from the config file or default
>                int steps = 2 * seconds;
>                int chunk = seconds * 1000000 / steps;
>                while (steps > 0) {
>                    // if the process exited, break the loop
>                    if (apr_proc_wait(&(proc_table[i].proc_id), &exitcode,
>                            &exitwhy, APR_NOWAIT) != APR_CHILD_NOTDONE)
{
>                        break;
>                    }
>                    // chunk must be in micro-seconds
>                    apr_sleep(chunk);
>                    steps--;
>                }
>                if (steps != 0) {
>                    proc_kill_force(&proc_table[i], main_server);
>                }
>            }

The biggest problem here is potentially waiting a long time for a
specific child process before moving on to the next. That's
potentially 30 seconds * huge-number.  Also, I think it is worthwhile
setting up the code so that it is easy to tweak the sleeps and
actions, like the MPMs have.

Look for ap_reclaim_child_processes() at
http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_unix.c?view=markup

Mime
View raw message