You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2020/06/23 16:39:25 UTC

svn commit: r1879119 - in /httpd/httpd/trunk: docs/log-message-tags/next-number modules/generators/mod_cgid.c

Author: jorton
Date: Tue Jun 23 16:39:25 2020
New Revision: 1879119

URL: http://svn.apache.org/viewvc?rev=1879119&view=rev
Log:
* modules/generators/mod_cgid.c (cgid_handler): Bail immediately with
  a 503 response on errors when talking to the daemon.  Check the pid
  returned is not zero.

Modified:
    httpd/httpd/trunk/docs/log-message-tags/next-number
    httpd/httpd/trunk/modules/generators/mod_cgid.c

Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1879119&r1=1879118&r2=1879119&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Tue Jun 23 16:39:25 2020
@@ -1 +1 @@
-10245
+10247

Modified: httpd/httpd/trunk/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_cgid.c?rev=1879119&r1=1879118&r2=1879119&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_cgid.c Tue Jun 23 16:39:25 2020
@@ -1629,8 +1629,8 @@ static int cgid_handler(request_rec *r)
 
     rv = send_req(sd, errpipe_out, r, argv0, env, CGI_REQ);
     if (rv != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01268)
-                     "write to cgi daemon process");
+        return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, rv, APLOGNO(10245)
+                               "could not send request to cgi daemon");
     }
 
     /* The write-end of the pipe is only used by the server, so close
@@ -1642,13 +1642,15 @@ static int cgid_handler(request_rec *r)
     info->r = r;
     rv = get_cgi_pid(r, conf, &(info->pid));
 
-    if (APR_SUCCESS == rv){  
+    /* Don't accept zero as a pid here, calling kill(0, SIGTERM) etc
+     * later is unpleasant. */
+    if (rv == APR_SUCCESS && info->pid) {
         apr_pool_cleanup_register(r->pool, info,
-                              cleanup_script,
-                              apr_pool_cleanup_null);
+                                  cleanup_script, apr_pool_cleanup_null);
     }
     else { 
-        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "error determining cgi PID");
+        return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, rv, APLOGNO(10246)
+                               "failed reading PID from cgi daemon");
     }
 
     /* We are putting the socket discriptor into an apr_file_t so that we can