summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
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();