Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FPM: Change last_idle_child lookup to fix idle time computation #4104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions sapi/fpm/fpm/fpm_process_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
struct fpm_child_s *child;
struct fpm_child_s *last_idle_child = NULL;
struct timeval last_idle_child_activity, child_activity;
int idle = 0;
int active = 0;
int children_to_fork;
Expand All @@ -324,9 +325,12 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
if (fpm_request_is_idle(child)) {
if (last_idle_child == NULL) {
last_idle_child = child;
fpm_request_last_activity(last_idle_child, &last_idle_child_activity);
} else {
if (timercmp(&child->started, &last_idle_child->started, <)) {
fpm_request_last_activity(child, &child_activity);
if (timercmp(&child_activity, &last_idle_child_activity, <)) {
last_idle_child = child;
last_idle_child_activity = child_activity;
}
}
idle++;
Expand Down Expand Up @@ -356,15 +360,14 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{

/* this is specific to PM_STYLE_ONDEMAND */
if (wp->config->pm == PM_STYLE_ONDEMAND) {
struct timeval last, now;
struct timeval now;

zlog(ZLOG_DEBUG, "[pool %s] currently %d active children, %d spare children", wp->config->name, active, idle);

if (!last_idle_child) continue;

fpm_request_last_activity(last_idle_child, &last);
fpm_clock_get(&now);
if (last.tv_sec < now.tv_sec - wp->config->pm_process_idle_timeout) {
if (last_idle_child_activity.tv_sec < now.tv_sec - wp->config->pm_process_idle_timeout) {
last_idle_child->idle_kill = 1;
fpm_pctl_kill(last_idle_child->pid, FPM_PCTL_QUIT);
}
Expand Down