You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Frank J. Faubert, Jr." <fr...@sane.com> on 1997/11/13 14:58:56 UTC

Re: NT BUG: Problem in master_main

Hi Sameer,

     No, they should shut down a lot faster than Apache does :)  There are
still some problems with the way the service shuts down on NT, but I don't
know enough about the Apache code base to know why it does certain things
(it may even be by design).  When the service is told to shut down, Apache
goes into the loop below and signals the children to stop.  After a 60
second time out (my patch makes it timeout after 60 seconds instead of
looping forever), it calls TerminateProcess on all of the children, which
just kills them then and there without giving them a chance to clean up.
The problem that I noticed is that if the child receives the signal that the
service is trying to shut down, and if the child is currently idle, it does
nothing.  It doesn't exit until after the child services the next request.
If the child could be made to shutdown if it is idle, Apache would shutdown
almost instantaneously when you tell the service to stop.
    Unfortunately, as I said above, I don't know enough about the code base
yet to solve this one.  I also can't seem to get a child server in debug
mode to try to step through the code.  Then again, this might be by design?

-Frank

-----Original Message-----
From: sameer <sa...@c2.net>
To: new-httpd@apache.org <ne...@apache.org>
Cc: new-httpd@apache.org <ne...@apache.org>
Date: Thursday, November 13, 1997 5:30 PM
Subject: Re: NT BUG: Problem in master_main


>(and here I was thinking that -all- NT services take that long to
shutdown.)
>
>> Hi,
>>
>>     I found a problem in master_main where a for loop would never end
>> because the "tmstart" and "time(NULL)" were in the wrong place.  The
>> following patch fixes it.  This should solve the problem where apache
takes
>> a long time to terminate as a Windows NT Service.
>>
>> -Frank
>>
>> *** http_main.c.orig    Thu Nov 13 17:05:33 1997
>> --- http_main.c Thu Nov 13 17:07:13 1997
>> ***************
>> *** 4250,4256 ****
>>         SetEvent(ev[i]);
>>       }
>> !     for (tmstart = time(NULL); nchild && (tmstart < (time(NULL) +
60));) {
>>         service_set_status(SERVICE_STOP_PENDING);
>>         rv = WaitForMultipleObjects(nchild, (HANDLE *) child, FALSE,
2000);
>>         ap_assert(rv != WAIT_FAILED);
>> --- 4250,4256 ----
>>         SetEvent(ev[i]);
>>       }
>> !     for (tmstart = time(NULL); nchild && (time(NULL) < (tmstart +
60));) {
>>         service_set_status(SERVICE_STOP_PENDING);
>>         rv = WaitForMultipleObjects(nchild, (HANDLE *) child, FALSE,
2000);
>>         ap_assert(rv != WAIT_FAILED);
>>
>
>
>--
>Sameer Parekh Voice:   510-986-8770
>President FAX:     510-986-8777
>C2Net
>http://www.c2.net/ sameer@c2.net
>


Re: NT BUG: Problem in master_main

Posted by Dean Gaudet <dg...@arctic.org>.
It's unlikely this is by design ... if the child is between requests it
absolutely should shutdown when told so ... that's how the unix side
behaves.

Dean

On Thu, 13 Nov 1997, Frank J. Faubert, Jr. wrote:

> Hi Sameer,
> 
>      No, they should shut down a lot faster than Apache does :)  There are
> still some problems with the way the service shuts down on NT, but I don't
> know enough about the Apache code base to know why it does certain things
> (it may even be by design).  When the service is told to shut down, Apache
> goes into the loop below and signals the children to stop.  After a 60
> second time out (my patch makes it timeout after 60 seconds instead of
> looping forever), it calls TerminateProcess on all of the children, which
> just kills them then and there without giving them a chance to clean up.
> The problem that I noticed is that if the child receives the signal that the
> service is trying to shut down, and if the child is currently idle, it does
> nothing.  It doesn't exit until after the child services the next request.
> If the child could be made to shutdown if it is idle, Apache would shutdown
> almost instantaneously when you tell the service to stop.
>     Unfortunately, as I said above, I don't know enough about the code base
> yet to solve this one.  I also can't seem to get a child server in debug
> mode to try to step through the code.  Then again, this might be by design?
> 
> -Frank
> 
> -----Original Message-----
> From: sameer <sa...@c2.net>
> To: new-httpd@apache.org <ne...@apache.org>
> Cc: new-httpd@apache.org <ne...@apache.org>
> Date: Thursday, November 13, 1997 5:30 PM
> Subject: Re: NT BUG: Problem in master_main
> 
> 
> >(and here I was thinking that -all- NT services take that long to
> shutdown.)
> >
> >> Hi,
> >>
> >>     I found a problem in master_main where a for loop would never end
> >> because the "tmstart" and "time(NULL)" were in the wrong place.  The
> >> following patch fixes it.  This should solve the problem where apache
> takes
> >> a long time to terminate as a Windows NT Service.
> >>
> >> -Frank
> >>
> >> *** http_main.c.orig    Thu Nov 13 17:05:33 1997
> >> --- http_main.c Thu Nov 13 17:07:13 1997
> >> ***************
> >> *** 4250,4256 ****
> >>         SetEvent(ev[i]);
> >>       }
> >> !     for (tmstart = time(NULL); nchild && (tmstart < (time(NULL) +
> 60));) {
> >>         service_set_status(SERVICE_STOP_PENDING);
> >>         rv = WaitForMultipleObjects(nchild, (HANDLE *) child, FALSE,
> 2000);
> >>         ap_assert(rv != WAIT_FAILED);
> >> --- 4250,4256 ----
> >>         SetEvent(ev[i]);
> >>       }
> >> !     for (tmstart = time(NULL); nchild && (time(NULL) < (tmstart +
> 60));) {
> >>         service_set_status(SERVICE_STOP_PENDING);
> >>         rv = WaitForMultipleObjects(nchild, (HANDLE *) child, FALSE,
> 2000);
> >>         ap_assert(rv != WAIT_FAILED);
> >>
> >
> >
> >--
> >Sameer Parekh Voice:   510-986-8770
> >President FAX:     510-986-8777
> >C2Net
> >http://www.c2.net/ sameer@c2.net
> >
> 
>