|
|
bdaebd |
diff --git a/include/scoreboard.h b/include/scoreboard.h
|
|
|
bdaebd |
index 9376da2..92d198d 100644
|
|
|
bdaebd |
--- a/include/scoreboard.h
|
|
|
bdaebd |
+++ b/include/scoreboard.h
|
|
|
bdaebd |
@@ -148,7 +148,9 @@ struct process_score {
|
|
|
bdaebd |
apr_uint32_t lingering_close; /* async connections in lingering close */
|
|
|
bdaebd |
apr_uint32_t keep_alive; /* async connections in keep alive */
|
|
|
bdaebd |
apr_uint32_t suspended; /* connections suspended by some module */
|
|
|
bdaebd |
- int bucket; /* Listener bucket used by this child */
|
|
|
bdaebd |
+ int bucket; /* Listener bucket used by this child; this field is DEPRECATED
|
|
|
bdaebd |
+ * and no longer updated by the MPMs (i.e. always zero).
|
|
|
bdaebd |
+ */
|
|
|
bdaebd |
};
|
|
|
bdaebd |
|
|
|
bdaebd |
/* Scoreboard is now in 'local' memory, since it isn't updated once created,
|
|
|
bdaebd |
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c
|
|
|
bdaebd |
index ffe8a23..048ae61 100644
|
|
|
bdaebd |
--- a/server/mpm/event/event.c
|
|
|
bdaebd |
+++ b/server/mpm/event/event.c
|
|
|
bdaebd |
@@ -2695,7 +2695,6 @@ static int make_child(server_rec * s, int slot, int bucket)
|
|
|
bdaebd |
|
|
|
bdaebd |
ap_scoreboard_image->parent[slot].quiescing = 0;
|
|
|
bdaebd |
ap_scoreboard_image->parent[slot].not_accepting = 0;
|
|
|
bdaebd |
- ap_scoreboard_image->parent[slot].bucket = bucket;
|
|
|
bdaebd |
event_note_child_started(slot, pid);
|
|
|
bdaebd |
active_daemons++;
|
|
|
bdaebd |
retained->total_daemons++;
|
|
|
bdaebd |
@@ -2734,6 +2733,7 @@ static void perform_idle_server_maintenance(int child_bucket, int num_buckets)
|
|
|
bdaebd |
* that threads_per_child is always > 0 */
|
|
|
bdaebd |
int status = SERVER_DEAD;
|
|
|
bdaebd |
int child_threads_active = 0;
|
|
|
bdaebd |
+ int bucket = i % num_buckets;
|
|
|
bdaebd |
|
|
|
bdaebd |
if (i >= retained->max_daemons_limit &&
|
|
|
bdaebd |
free_length == retained->idle_spawn_rate[child_bucket]) {
|
|
|
bdaebd |
@@ -2757,7 +2757,7 @@ static void perform_idle_server_maintenance(int child_bucket, int num_buckets)
|
|
|
bdaebd |
*/
|
|
|
bdaebd |
if (status <= SERVER_READY && !ps->quiescing && !ps->not_accepting
|
|
|
bdaebd |
&& ps->generation == retained->mpm->my_generation
|
|
|
bdaebd |
- && ps->bucket == child_bucket)
|
|
|
bdaebd |
+ && bucket == child_bucket)
|
|
|
bdaebd |
{
|
|
|
bdaebd |
++idle_thread_count;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
@@ -2768,7 +2768,9 @@ static void perform_idle_server_maintenance(int child_bucket, int num_buckets)
|
|
|
bdaebd |
last_non_dead = i;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
active_thread_count += child_threads_active;
|
|
|
bdaebd |
- if (!ps->pid && free_length < retained->idle_spawn_rate[child_bucket])
|
|
|
bdaebd |
+ if (!ps->pid
|
|
|
bdaebd |
+ && bucket == child_bucket
|
|
|
bdaebd |
+ && free_length < retained->idle_spawn_rate[child_bucket])
|
|
|
bdaebd |
free_slots[free_length++] = i;
|
|
|
bdaebd |
else if (child_threads_active == threads_per_child)
|
|
|
bdaebd |
had_healthy_child = 1;
|
|
|
bdaebd |
@@ -2951,13 +2953,14 @@ static void server_main_loop(int remaining_children_to_start, int num_buckets)
|
|
|
bdaebd |
retained->total_daemons--;
|
|
|
bdaebd |
if (processed_status == APEXIT_CHILDSICK) {
|
|
|
bdaebd |
/* resource shortage, minimize the fork rate */
|
|
|
bdaebd |
- retained->idle_spawn_rate[ps->bucket] = 1;
|
|
|
bdaebd |
+ retained->idle_spawn_rate[child_slot % num_buckets] = 1;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
else if (remaining_children_to_start) {
|
|
|
bdaebd |
/* we're still doing a 1-for-1 replacement of dead
|
|
|
bdaebd |
* children with new children
|
|
|
bdaebd |
*/
|
|
|
bdaebd |
- make_child(ap_server_conf, child_slot, ps->bucket);
|
|
|
bdaebd |
+ make_child(ap_server_conf, child_slot,
|
|
|
bdaebd |
+ child_slot % num_buckets);
|
|
|
bdaebd |
--remaining_children_to_start;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
}
|
|
|
bdaebd |
diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c
|
|
|
bdaebd |
index 8efda72..7c00625 100644
|
|
|
bdaebd |
--- a/server/mpm/prefork/prefork.c
|
|
|
bdaebd |
+++ b/server/mpm/prefork/prefork.c
|
|
|
bdaebd |
@@ -637,8 +637,9 @@ static void child_main(int child_num_arg, int child_bucket)
|
|
|
bdaebd |
}
|
|
|
bdaebd |
|
|
|
bdaebd |
|
|
|
bdaebd |
-static int make_child(server_rec *s, int slot, int bucket)
|
|
|
bdaebd |
+static int make_child(server_rec *s, int slot)
|
|
|
bdaebd |
{
|
|
|
bdaebd |
+ int bucket = slot % retained->mpm->num_buckets;
|
|
|
bdaebd |
int pid;
|
|
|
bdaebd |
|
|
|
bdaebd |
if (slot + 1 > retained->max_daemons_limit) {
|
|
|
bdaebd |
@@ -716,7 +717,6 @@ static int make_child(server_rec *s, int slot, int bucket)
|
|
|
bdaebd |
child_main(slot, bucket);
|
|
|
bdaebd |
}
|
|
|
bdaebd |
|
|
|
bdaebd |
- ap_scoreboard_image->parent[slot].bucket = bucket;
|
|
|
bdaebd |
prefork_note_child_started(slot, pid);
|
|
|
bdaebd |
|
|
|
bdaebd |
return 0;
|
|
|
bdaebd |
@@ -732,7 +732,7 @@ static void startup_children(int number_to_start)
|
|
|
bdaebd |
if (ap_scoreboard_image->servers[i][0].status != SERVER_DEAD) {
|
|
|
bdaebd |
continue;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
- if (make_child(ap_server_conf, i, i % retained->mpm->num_buckets) < 0) {
|
|
|
bdaebd |
+ if (make_child(ap_server_conf, i) < 0) {
|
|
|
bdaebd |
break;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
--number_to_start;
|
|
|
bdaebd |
@@ -741,8 +741,6 @@ static void startup_children(int number_to_start)
|
|
|
bdaebd |
|
|
|
bdaebd |
static void perform_idle_server_maintenance(apr_pool_t *p)
|
|
|
bdaebd |
{
|
|
|
bdaebd |
- static int bucket_make_child_record = -1;
|
|
|
bdaebd |
- static int bucket_kill_child_record = -1;
|
|
|
bdaebd |
int i;
|
|
|
bdaebd |
int idle_count;
|
|
|
bdaebd |
worker_score *ws;
|
|
|
bdaebd |
@@ -789,6 +787,7 @@ static void perform_idle_server_maintenance(apr_pool_t *p)
|
|
|
bdaebd |
}
|
|
|
bdaebd |
retained->max_daemons_limit = last_non_dead + 1;
|
|
|
bdaebd |
if (idle_count > ap_daemons_max_free) {
|
|
|
bdaebd |
+ static int bucket_kill_child_record = -1;
|
|
|
bdaebd |
/* kill off one child... we use the pod because that'll cause it to
|
|
|
bdaebd |
* shut down gracefully, in case it happened to pick up a request
|
|
|
bdaebd |
* while we were counting
|
|
|
bdaebd |
@@ -819,10 +818,7 @@ static void perform_idle_server_maintenance(apr_pool_t *p)
|
|
|
bdaebd |
idle_count, total_non_dead);
|
|
|
bdaebd |
}
|
|
|
bdaebd |
for (i = 0; i < free_length; ++i) {
|
|
|
bdaebd |
- bucket_make_child_record++;
|
|
|
bdaebd |
- bucket_make_child_record %= retained->mpm->num_buckets;
|
|
|
bdaebd |
- make_child(ap_server_conf, free_slots[i],
|
|
|
bdaebd |
- bucket_make_child_record);
|
|
|
bdaebd |
+ make_child(ap_server_conf, free_slots[i]);
|
|
|
bdaebd |
}
|
|
|
bdaebd |
/* the next time around we want to spawn twice as many if this
|
|
|
bdaebd |
* wasn't good enough, but not if we've just done a graceful
|
|
|
bdaebd |
@@ -867,7 +863,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
|
|
|
bdaebd |
|
|
|
bdaebd |
if (one_process) {
|
|
|
bdaebd |
AP_MONCONTROL(1);
|
|
|
bdaebd |
- make_child(ap_server_conf, 0, 0);
|
|
|
bdaebd |
+ make_child(ap_server_conf, 0);
|
|
|
bdaebd |
/* NOTREACHED */
|
|
|
bdaebd |
ap_assert(0);
|
|
|
bdaebd |
return !OK;
|
|
|
bdaebd |
@@ -976,8 +972,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
|
|
|
bdaebd |
/* we're still doing a 1-for-1 replacement of dead
|
|
|
bdaebd |
* children with new children
|
|
|
bdaebd |
*/
|
|
|
bdaebd |
- make_child(ap_server_conf, child_slot,
|
|
|
bdaebd |
- ap_get_scoreboard_process(child_slot)->bucket);
|
|
|
bdaebd |
+ make_child(ap_server_conf, child_slot);
|
|
|
bdaebd |
--remaining_children_to_start;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
#if APR_HAS_OTHER_CHILD
|
|
|
bdaebd |
diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c
|
|
|
bdaebd |
index 8012fe2..a927942 100644
|
|
|
bdaebd |
--- a/server/mpm/worker/worker.c
|
|
|
bdaebd |
+++ b/server/mpm/worker/worker.c
|
|
|
bdaebd |
@@ -1339,7 +1339,6 @@ static int make_child(server_rec *s, int slot, int bucket)
|
|
|
bdaebd |
worker_note_child_lost_slot(slot, pid);
|
|
|
bdaebd |
}
|
|
|
bdaebd |
ap_scoreboard_image->parent[slot].quiescing = 0;
|
|
|
bdaebd |
- ap_scoreboard_image->parent[slot].bucket = bucket;
|
|
|
bdaebd |
worker_note_child_started(slot, pid);
|
|
|
bdaebd |
return 0;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
@@ -1388,6 +1387,7 @@ static void perform_idle_server_maintenance(int child_bucket, int num_buckets)
|
|
|
bdaebd |
int any_dead_threads = 0;
|
|
|
bdaebd |
int all_dead_threads = 1;
|
|
|
bdaebd |
int child_threads_active = 0;
|
|
|
bdaebd |
+ int bucket = i % num_buckets;
|
|
|
bdaebd |
|
|
|
bdaebd |
if (i >= retained->max_daemons_limit &&
|
|
|
bdaebd |
totally_free_length == retained->idle_spawn_rate[child_bucket]) {
|
|
|
bdaebd |
@@ -1420,7 +1420,7 @@ static void perform_idle_server_maintenance(int child_bucket, int num_buckets)
|
|
|
bdaebd |
if (status <= SERVER_READY &&
|
|
|
bdaebd |
!ps->quiescing &&
|
|
|
bdaebd |
ps->generation == retained->mpm->my_generation &&
|
|
|
bdaebd |
- ps->bucket == child_bucket) {
|
|
|
bdaebd |
+ bucket == child_bucket) {
|
|
|
bdaebd |
++idle_thread_count;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
if (status >= SERVER_READY && status < SERVER_GRACEFUL) {
|
|
|
bdaebd |
@@ -1430,6 +1430,7 @@ static void perform_idle_server_maintenance(int child_bucket, int num_buckets)
|
|
|
bdaebd |
}
|
|
|
bdaebd |
active_thread_count += child_threads_active;
|
|
|
bdaebd |
if (any_dead_threads
|
|
|
bdaebd |
+ && bucket == child_bucket
|
|
|
bdaebd |
&& totally_free_length < retained->idle_spawn_rate[child_bucket]
|
|
|
bdaebd |
&& free_length < MAX_SPAWN_RATE / num_buckets
|
|
|
bdaebd |
&& (!ps->pid /* no process in the slot */
|
|
|
bdaebd |
@@ -1615,14 +1616,15 @@ static void server_main_loop(int remaining_children_to_start, int num_buckets)
|
|
|
bdaebd |
ps->quiescing = 0;
|
|
|
bdaebd |
if (processed_status == APEXIT_CHILDSICK) {
|
|
|
bdaebd |
/* resource shortage, minimize the fork rate */
|
|
|
bdaebd |
- retained->idle_spawn_rate[ps->bucket] = 1;
|
|
|
bdaebd |
+ retained->idle_spawn_rate[child_slot % num_buckets] = 1;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
else if (remaining_children_to_start
|
|
|
bdaebd |
&& child_slot < ap_daemons_limit) {
|
|
|
bdaebd |
/* we're still doing a 1-for-1 replacement of dead
|
|
|
bdaebd |
* children with new children
|
|
|
bdaebd |
*/
|
|
|
bdaebd |
- make_child(ap_server_conf, child_slot, ps->bucket);
|
|
|
bdaebd |
+ make_child(ap_server_conf, child_slot,
|
|
|
bdaebd |
+ child_slot % num_buckets);
|
|
|
bdaebd |
--remaining_children_to_start;
|
|
|
bdaebd |
}
|
|
|
bdaebd |
}
|