httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1368452 - in /httpd/httpd/branches/2.4.x: ./ STATUS server/mpm/event/event.c
Date Thu, 02 Aug 2012 13:08:43 GMT
Author: jim
Date: Thu Aug  2 13:08:43 2012
New Revision: 1368452

URL: http://svn.apache.org/viewvc?rev=1368452&view=rev
Log:
Merge r1361766 from trunk:

Simplify handling of MaxConnectionsPerChild

If we decrement the counter at accept time and not at close time,
we only need to access the counter in the listener thread and the
code gets much simpler.

Submitted by: sf
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/server/mpm/event/event.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1361766

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1368452&r1=1368451&r2=1368452&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Thu Aug  2 13:08:43 2012
@@ -88,11 +88,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * event: Simplify handling of MaxConnectionsPerChild.
-     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1361766
-     2.4.x patch: Trunk patch applies.
-     +1: rjung, sf, jim
-
    * headers: ap_str(case)cmp_match returns the opposite of what is advertized
      in the header.
      trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1366319

Modified: httpd/httpd/branches/2.4.x/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/mpm/event/event.c?rev=1368452&r1=1368451&r2=1368452&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/mpm/event/event.c (original)
+++ httpd/httpd/branches/2.4.x/server/mpm/event/event.c Thu Aug  2 13:08:43 2012
@@ -172,14 +172,9 @@ static int workers_may_exit = 0;
 static int start_thread_may_exit = 0;
 static int listener_may_exit = 0;
 static int num_listensocks = 0;
-/*
- * As we don't have APR atomic functions for apr_int32_t, we use apr_uint32_t
- * to actually store a signed value. This works as long as the platform uses
- * two's complement representation. This assumption is also made in other
- * parts of the code (e.g. fdqueue.c).
- */
-static apr_uint32_t conns_this_child;
-static apr_uint32_t connection_count = 0;
+static apr_int32_t conns_this_child;        /* MaxConnectionsPerChild, only access
+                                               in listener thread */
+static apr_uint32_t connection_count = 0;   /* Number of open connections */
 static int resource_shortage = 0;
 static fd_queue_t *worker_queue;
 static fd_queue_info_t *worker_queue_info;
@@ -596,7 +591,6 @@ static int volatile restart_pending;
 
 static apr_status_t decrement_connection_count(void *dummy) {
     apr_atomic_dec32(&connection_count);
-    apr_atomic_dec32(&conns_this_child);
     return APR_SUCCESS;
 }
 
@@ -882,7 +876,6 @@ static void process_socket(apr_thread_t 
             apr_bucket_alloc_destroy(cs->bucket_alloc);
             apr_pool_clear(p);
             ap_push_pool(worker_queue_info, p);
-            apr_atomic_dec32(&conns_this_child);
             return;
         }
         apr_atomic_inc32(&connection_count);
@@ -1049,7 +1042,7 @@ static void check_infinite_requests(void
     }
     else {
         /* keep going */
-        apr_atomic_set32(&conns_this_child, APR_INT32_MAX);
+        conns_this_child = APR_INT32_MAX;
     }
 }
 
@@ -1395,9 +1388,8 @@ static void * APR_THREAD_FUNC listener_t
                 break;
         }
 
-        if (((apr_int32_t)apr_atomic_read32(&conns_this_child)) <= 0) {
+        if (conns_this_child <= 0)
             check_infinite_requests();
-        }
 
         now = apr_time_now();
         if (APLOGtrace6(ap_server_conf)) {
@@ -1600,6 +1592,7 @@ static void * APR_THREAD_FUNC listener_t
                     }
 
                     if (csd != NULL) {
+                        conns_this_child--;
                         rc = ap_queue_push(worker_queue, csd, NULL, ptrans);
                         if (rc != APR_SUCCESS) {
                             /* trash the connection; we couldn't queue the connected
@@ -2080,11 +2073,11 @@ static void child_main(int child_num_arg
     }
 
     if (ap_max_requests_per_child) {
-        apr_atomic_set32(&conns_this_child, (apr_uint32_t)ap_max_requests_per_child);
+        conns_this_child = ap_max_requests_per_child;
     }
     else {
         /* coding a value of zero means infinity */
-        apr_atomic_set32(&conns_this_child, APR_INT32_MAX);
+        conns_this_child = APR_INT32_MAX;
     }
 
     /* Setup worker threads */



Mime
View raw message