Attached is a patch that will make MaxRequestsPerChild act a little better
with keepalive requests.

I would have liked for a better way to turn off keepalive for the last
request of the child, than just terminating it, but I couldn't find a way
to turn off keepalive before the headers were sent and ap_process_request
was called.

-- 
  Thomas Eibner <http://thomas.eibner.dk/>

--- http_main.c.orig    Thu Apr 12 19:49:26 2001
+++ http_main.c Sun Jun  3 00:45:21 2001
@@ -3938,11 +3938,9 @@
 
 #ifndef WIN32
        if ((ap_max_requests_per_child > 0
-            && requests_this_child++ >= ap_max_requests_per_child)) {
+            && requests_this_child >= ap_max_requests_per_child)) {
            clean_child_exit(0);
        }
-#else
-       ++requests_this_child;
 #endif
 
        (void) ap_update_child_status(my_child_num, SERVER_READY, (request_rec *) 
NULL);
@@ -4201,6 +4199,8 @@
             * signal (SIGUSR1, SIG_IGN);
             */
 
+           ++requests_this_child;
+
            (void) ap_update_child_status(my_child_num, SERVER_BUSY_WRITE, r);
 
            /* process the request if it was read without error */
@@ -4210,6 +4210,10 @@
 
            if(ap_extended_status)
                increment_counts(my_child_num, r);
+
+           if ((ap_max_requests_per_child > 0 && current_conn->keepalive 
+               && requests_this_child >= ap_max_requests_per_child))
+               current_conn->keepalive = 0;
 
            if (!current_conn->keepalive || current_conn->aborted)
                break;

Reply via email to