1
0
mirror of https://github.com/apache/httpd.git synced 2026-01-13 21:42:17 +03:00

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
This commit is contained in:
Yann Ylavic
2014-11-17 13:59:36 +00:00
parent c5d85f6439
commit 9d670bcfdf
3 changed files with 56 additions and 18 deletions

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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();