httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1640161 - in /httpd/httpd/trunk/server/mpm: event/event.c eventopt/eventopt.c worker/worker.c
Date Mon, 17 Nov 2014 13:59:37 GMT
Author: ylavic
Date: Mon Nov 17 13:59:36 2014
New Revision: 1640161

URL: http://svn.apache.org/r1640161
Log:
mpm_event(opt), mpm_worker, mpm_prefork: follow up to r1635521.
Allocate retained idle_spawn_rate vector on the process pool.

Modified:
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/eventopt/eventopt.c
    httpd/httpd/trunk/server/mpm/worker/worker.c

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1640161&r1=1640160&r2=1640161&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Mon Nov 17 13:59:36 2014
@@ -353,7 +353,8 @@ typedef struct event_retained_data {
      * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
      * without the need to spawn.
      */
-    int *idle_spawn_rate;
+    int *idle_spawn_rate,
+         idle_spawn_rate_len;
 #ifndef MAX_SPAWN_RATE
 #define MAX_SPAWN_RATE        (32)
 #endif
@@ -3223,6 +3224,22 @@ static int event_open_logs(apr_pool_t * 
         all_buckets[i].listeners = listen_buckets[i];
     }
 
+    if (retained->idle_spawn_rate_len < num_buckets) {
+        int *new_ptr, new_len;
+        new_len = retained->idle_spawn_rate_len * 2;
+        if (new_len < num_buckets) {
+            new_len = num_buckets;
+        }
+        new_ptr = (int *)apr_palloc(ap_pglobal, new_len * sizeof(int));
+        memcpy(new_ptr, retained->idle_spawn_rate,
+               retained->idle_spawn_rate_len * sizeof(int));
+        for (i = retained->idle_spawn_rate_len; i < new_len; i++) {
+            new_ptr[i] = 1;
+        }
+        retained->idle_spawn_rate_len = new_len;
+        retained->idle_spawn_rate = new_ptr;
+    }
+
     /* for skiplist */
     srand((unsigned int)apr_time_now());
     return OK;
@@ -3234,7 +3251,6 @@ static int event_pre_config(apr_pool_t *
     int no_detach, debug, foreground;
     apr_status_t rv;
     const char *userdata_key = "mpm_event_module";
-    int i;
 
     mpm_state = AP_MPMQ_STARTING;
 
@@ -3268,10 +3284,7 @@ static int event_pre_config(apr_pool_t *
                          "atomics not working as expected - add32 of negative number");
             return HTTP_INTERNAL_SERVER_ERROR;
         }
-        retained->idle_spawn_rate = apr_palloc(pconf, sizeof(int) * num_buckets);
-        for (i = 0; i< num_buckets; i++) {
-            retained->idle_spawn_rate[i] = 1;
-        }
+
         rv = apr_pollset_create(&event_pollset, 1, plog,
                                 APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY);
         if (rv != APR_SUCCESS) {

Modified: httpd/httpd/trunk/server/mpm/eventopt/eventopt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/eventopt.c?rev=1640161&r1=1640160&r2=1640161&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/eventopt.c (original)
+++ httpd/httpd/trunk/server/mpm/eventopt/eventopt.c Mon Nov 17 13:59:36 2014
@@ -338,7 +338,8 @@ typedef struct event_retained_data {
      * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
      * without the need to spawn.
      */
-    int *idle_spawn_rate;
+    int *idle_spawn_rate,
+         idle_spawn_rate_len;
 #ifndef MAX_SPAWN_RATE
 #define MAX_SPAWN_RATE        (32)
 #endif
@@ -3042,6 +3043,22 @@ static int event_open_logs(apr_pool_t * 
         all_buckets[i].listeners = listen_buckets[i];
     }
 
+    if (retained->idle_spawn_rate_len < num_buckets) {
+        int *new_ptr, new_len;
+        new_len = retained->idle_spawn_rate_len * 2;
+        if (new_len < num_buckets) {
+            new_len = num_buckets;
+        }
+        new_ptr = (int *)apr_palloc(ap_pglobal, new_len * sizeof(int));
+        memcpy(new_ptr, retained->idle_spawn_rate,
+               retained->idle_spawn_rate_len * sizeof(int));
+        for (i = retained->idle_spawn_rate_len; i < new_len; i++) {
+            new_ptr[i] = 1;
+        }
+        retained->idle_spawn_rate_len = new_len;
+        retained->idle_spawn_rate = new_ptr;
+    }
+
     /* for skiplist */
     srand((unsigned int)apr_time_now());
     return OK;
@@ -3053,7 +3070,6 @@ static int event_pre_config(apr_pool_t *
     int no_detach, debug, foreground;
     apr_status_t rv;
     const char *userdata_key = "mpm_eventopt_module";
-    int i;
 
     mpm_state = AP_MPMQ_STARTING;
 
@@ -3087,10 +3103,7 @@ static int event_pre_config(apr_pool_t *
                          "atomics not working as expected - add32 of negative number");
             return HTTP_INTERNAL_SERVER_ERROR;
         }
-        retained->idle_spawn_rate = apr_palloc(pconf, sizeof(int) * num_buckets);
-        for (i = 0; i< num_buckets; i++) {
-            retained->idle_spawn_rate[i] = 1;
-        }
+
         rv = apr_pollset_create(&event_pollset, 1, plog,
                                 APR_POLLSET_WAKEABLE|APR_POLLSET_NOCOPY);
         if (rv != APR_SUCCESS) {

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=1640161&r1=1640160&r2=1640161&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Mon Nov 17 13:59:36 2014
@@ -163,7 +163,8 @@ typedef struct worker_retained_data {
      * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
      * without the need to spawn.
      */
-    int *idle_spawn_rate;
+    int *idle_spawn_rate,
+         idle_spawn_rate_len;
 #ifndef MAX_SPAWN_RATE
 #define MAX_SPAWN_RATE        (32)
 #endif
@@ -2057,6 +2058,22 @@ static int worker_open_logs(apr_pool_t *
         all_buckets[i].listeners = listen_buckets[i];
     }
 
+    if (retained->idle_spawn_rate_len < num_buckets) {
+        int *new_ptr, new_len;
+        new_len = retained->idle_spawn_rate_len * 2;
+        if (new_len < num_buckets) {
+            new_len = num_buckets;
+        }
+        new_ptr = (int *)apr_palloc(ap_pglobal, new_len * sizeof(int));
+        memcpy(new_ptr, retained->idle_spawn_rate,
+               retained->idle_spawn_rate_len * sizeof(int));
+        for (i = retained->idle_spawn_rate_len; i < new_len; i++) {
+            new_ptr[i] = 1;
+        }
+        retained->idle_spawn_rate_len = new_len;
+        retained->idle_spawn_rate = new_ptr;
+    }
+
     return OK;
 }
 
@@ -2066,7 +2083,6 @@ static int worker_pre_config(apr_pool_t 
     int no_detach, debug, foreground;
     apr_status_t rv;
     const char *userdata_key = "mpm_worker_module";
-    int i;
 
     mpm_state = AP_MPMQ_STARTING;
 
@@ -2103,10 +2119,6 @@ static int worker_pre_config(apr_pool_t 
                 return HTTP_INTERNAL_SERVER_ERROR;
             }
         }
-        retained->idle_spawn_rate = apr_palloc(pconf, sizeof(int) * num_buckets);
-        for (i = 0; i< num_buckets; i++) {
-            retained->idle_spawn_rate[i] = 1;
-        }
     }
 
     parent_pid = ap_my_pid = getpid();



Mime
View raw message