httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <>
Subject Re: Showstopper? Inheritence, CGI Exec() changes bad for cgid
Date Fri, 28 Mar 2003 22:11:36 GMT
This patch seems to be one issue;

--- httpd-2.0/modules/generators/mod_cgid.c	2003/02/03 17:31:39
+++ httpd-2.0/modules/generators/mod_cgid.c	2003/02/27 12:33:08
+static void cgid_child_errfn(apr_pool_t *pool, apr_status_t err,
+                             const char *description)
+    request_rec *r;
+    void *vr;
+    apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool);
+    r = vr;
+    /* sure we got r, but don't call ap_log_rerror() because we don't
+     * have r->headers_in and possibly other storage referenced by
+     * ap_log_rerror()
+     */
+    ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, "%s", description);

We can't call ap_log_error after we've invoked the child_cleanups 
because all those oddball log files are already closed.

I see a couple quick choices... inherit the "REAL" log handle as fd3
to every cgi process and print to that fd.  Print such a log message
to stderr/fd2.  Or toggle the log handle as FD_CLOEXEC but remove
it's cleanup function.

Finally, we see fatal SIGPIPE's on Solaris... it looks like we need 
to do something like;

Index: modules/generators/mod_cgid.c
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
retrieving revision
diff -u -r1.145.2.3 mod_cgid.c
--- modules/generators/mod_cgid.c	27 Feb 2003 12:33:08 -0000
+++ modules/generators/mod_cgid.c	28 Mar 2003 22:07:12 -0000
@@ -600,5 +600,13 @@
     apr_pool_create(&ptrans, pcgi); 
+    /* The child process doesn't do anything for AP_SIG_GRACEFUL.  
+     * and family.  Instead, SIGHUP is used for signalling restart.
+     */
     apr_signal(SIGCHLD, SIG_IGN); 
+    apr_signal(AP_SIG_GRACEFUL, SIG_IGN);
+    apr_signal(SIGTERM, SIG_IGN);
+#ifdef SIGPIPE
+    apr_signal(SIGPIPE, SIG_IGN);
     apr_signal(SIGHUP, daemon_signal_handler);

to cover some of the other signals we should be respecting/ignoring
in the cgid worker process.

Oh, and this code;

        case APR_OC_REASON_LOST:
            /* it would be better to restart just the cgid child
             * process but for now we'll gracefully restart the entire 
             * server by sending AP_SIG_GRACEFUL to ourself, the httpd 
             * parent process
            kill(getpid(), AP_SIG_GRACEFUL);

is broken when the child triggers it (wrong pid!!!)

Perhaps, why didn't we generate one cgid per worker process?  It would
make alot more sense if one child could begin it's own graceful shutdown
and let the parent replace it when its requests (that weren't CGI) are all


View raw message