Bug 38995 - httpd tries to communicate with the CGI daemon even after a graceful shutdown
Summary: httpd tries to communicate with the CGI daemon even after a graceful shutdown
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_cgid (show other bugs)
Version: 2.4-HEAD
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-16 13:00 UTC by Kiran Mendonce
Modified: 2013-07-05 10:21 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kiran Mendonce 2006-03-16 13:00:24 UTC
While running the bench marking tool, ab (options are -c 30 -n 400), on a cgi
script that takes about 30 seconds to complete, I notice the following error in
the logfile when I do a graceful shutdown. This is on 2.0.55 version of Apache.
The error I get is :

[Thu Mar 02 17:23:11 2006] [error] [client 15.42.227.146] daemon couldn't find C
GI process for connection 5
[Thu Mar 02 17:23:11 2006] [error] [client 15.42.227.146] daemon couldn't find C
GI process for connection 67

For every concurrent request issued, there seems to be an error.

I could fix this with some modifications to mod_cgid.c. I found that the httpd
process serving the CGI request tries to contact the daemon in the cleanup
callback even when a graceful restart has been issued. A check for a graceful
restart situation should be made before the connect. The following condition at
the beginning of cleanup_script() solves the problem :

   if (ap_graceful_stop_signalled())
       return APR_EGENERAL;
Comment 1 Dave 2013-07-05 10:21:35 UTC
Although this bug was raised against 2.0 in 2006, this behavior still exists on the latest 2.4. It can easily be reproduced by restarting Apache while running a simple curl loop against a phpinfo script (in other words while the server is only handling a single request to the CGI)

As ap_graceful_stop_signalled() was removed in 2.3, I suspect a modern equivalent before the connect() in cleanup_script() would be:

    /* Don't connect while we're shutting down */
    if (ap_mpm_query(AP_MPMQ_MPM_STATE, &rc) == APR_SUCCESS &&
        rc == AP_MPMQ_STOPPING) {
        return APR_EGENERAL;
    }

although I cannot vouch for the appropriateness of the reported workaround.