Skip to content
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

FPM: For pm = ondemand, don't respawn processes that reached pm.max_requests #4101

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions sapi/fpm/fpm/fpm.h
Expand Up @@ -34,6 +34,7 @@
#define FPM_EXIT_CONFIG 78
#endif

#define FPM_EXIT_MAX_REQUESTS 2

int fpm_run(int *max_requests);
int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr);
Expand Down
7 changes: 6 additions & 1 deletion sapi/fpm/fpm/fpm_children.c
Expand Up @@ -198,7 +198,10 @@ void fpm_children_bury() /* {{{ */
restart_child = 0;
}

if (WEXITSTATUS(status) != FPM_EXIT_OK) {
/* Don't restart processes for pm.ondemand if pm.max_requests has been reached. */
if (child && child->wp->config->pm == PM_STYLE_ONDEMAND && WEXITSTATUS(status) == FPM_EXIT_MAX_REQUESTS) {
restart_child = 0;
} else if (WEXITSTATUS(status) != FPM_EXIT_OK) {
severity = ZLOG_WARNING;
}

Expand Down Expand Up @@ -250,6 +253,8 @@ void fpm_children_bury() /* {{{ */
severity = ZLOG_DEBUG;
}
zlog(severity, "[pool %s] child %d exited %s after %ld.%06d seconds from start", child->wp->config->name, (int) pid, buf, tv2.tv_sec, (int) tv2.tv_usec);
} else if (WEXITSTATUS(status) == FPM_EXIT_MAX_REQUESTS) {
zlog(ZLOG_DEBUG, "[pool %s] child %d served pm.max_requests after %ld.%06d seconds from start", child->wp->config->name, (int) pid, tv2.tv_sec, (int) tv2.tv_usec);
} else {
zlog(ZLOG_DEBUG, "[pool %s] child %d has been killed by the process management after %ld.%06d seconds from start", child->wp->config->name, (int) pid, tv2.tv_sec, (int) tv2.tv_usec);
}
Expand Down
1 change: 1 addition & 0 deletions sapi/fpm/fpm/fpm_main.c
Expand Up @@ -1997,6 +1997,7 @@ consult the installation file that came with this distribution, or visit \n\
if (UNEXPECTED(max_requests && (requests == max_requests))) {
fcgi_request_set_keep(request, 0);
fcgi_finish_request(request, 0);
exit_status = FPM_EXIT_MAX_REQUESTS;
break;
}
/* end of fastcgi loop */
Expand Down