summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2014-11-17 14:59:36 +0100
committerYann Ylavic <ylavic@apache.org>2014-11-17 14:59:36 +0100
commit9d670bcfdf3a3c4fbf659178cb78de0ea985e9fa (patch)
tree31ff13d9f28e99c6f7e4148aa3c8c46a429360d0 /server
parentmpm_worker, mpm_prefork: follow up to r1635521. (diff)
downloadapache2-9d670bcfdf3a3c4fbf659178cb78de0ea985e9fa.tar.xz
apache2-9d670bcfdf3a3c4fbf659178cb78de0ea985e9fa.zip
mpm_event(opt), mpm_worker: follow up to r1635521.
Allocate retained idle_spawn_rate vector on the process pool. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1640161 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/mpm/event/event.c25
-rw-r--r--server/mpm/eventopt/eventopt.c25
-rw-r--r--server/mpm/worker/worker.c24
3 files changed, 56 insertions, 18 deletions
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c
index 6d5bdbf566..a5e312491b 100644
--- a/server/mpm/event/event.c
+++ b/server/mpm/event/event.c
@@ -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 * p, apr_pool_t * plog,
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 * pconf, apr_pool_t * plog,
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 * pconf, apr_pool_t * plog,
"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) {
diff --git a/server/mpm/eventopt/eventopt.c b/server/mpm/eventopt/eventopt.c
index 56239a563d..dd002ac831 100644
--- a/server/mpm/eventopt/eventopt.c
+++ b/server/mpm/eventopt/eventopt.c
@@ -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 * p, apr_pool_t * plog,
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 * pconf, apr_pool_t * plog,
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 * pconf, apr_pool_t * plog,
"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) {
diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c
index 890c825b31..0351c066d2 100644
--- a/server/mpm/worker/worker.c
+++ b/server/mpm/worker/worker.c
@@ -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 *p, apr_pool_t *plog, apr_pool_t *ptemp,
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 *pconf, apr_pool_t *plog,
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 *pconf, apr_pool_t *plog,
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();