Skip to content

Fix GH-10385: FPM successful config test early exit #10388

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
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions sapi/fpm/fpm/fpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct fpm_globals_s fpm_globals = {
.send_config_pipe = {0, 0},
};

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) /* {{{ */
enum fpm_init_return_status 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) /* {{{ */
{
fpm_globals.argc = argc;
fpm_globals.argv = argv;
Expand All @@ -67,22 +67,22 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int t
0 > fpm_event_init_main()) {

if (fpm_globals.test_successful) {
exit(FPM_EXIT_OK);
return FPM_INIT_EXIT_OK;
} else {
zlog(ZLOG_ERROR, "FPM initialization failed");
return -1;
return FPM_INIT_ERROR;
}
}

if (0 > fpm_conf_write_pid()) {
zlog(ZLOG_ERROR, "FPM initialization failed");
return -1;
return FPM_INIT_ERROR;
}

fpm_stdio_init_final();
zlog(ZLOG_NOTICE, "fpm is running, pid %d", (int) fpm_globals.parent_pid);

return 0;
return FPM_INIT_CONTINUE;
}
/* }}} */

Expand Down
8 changes: 7 additions & 1 deletion sapi/fpm/fpm/fpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@
#endif


enum fpm_init_return_status {
FPM_INIT_ERROR,
FPM_INIT_CONTINUE,
FPM_INIT_EXIT_OK,
};

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);
enum fpm_init_return_status 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);

struct fpm_globals_s {
pid_t parent_pid;
Expand Down
12 changes: 7 additions & 5 deletions sapi/fpm/fpm/fpm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,6 @@ int main(int argc, char *argv[])
int force_stderr = 0;
int php_information = 0;
int php_allow_to_run_as_root = 0;
int ret;
#if ZEND_RC_DEBUG
bool old_rc_debug;
#endif
Expand Down Expand Up @@ -1800,21 +1799,24 @@ consult the installation file that came with this distribution, or visit \n\
zend_rc_debug = 0;
#endif

ret = fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root, force_daemon, force_stderr);
enum fpm_init_return_status ret = fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root, force_daemon, force_stderr);

#if ZEND_RC_DEBUG
zend_rc_debug = old_rc_debug;
#endif

if (ret < 0) {

if (ret == FPM_INIT_ERROR) {
if (fpm_globals.send_config_pipe[1]) {
int writeval = 0;
zlog(ZLOG_DEBUG, "Sending \"0\" (error) to parent via fd=%d", fpm_globals.send_config_pipe[1]);
zend_quiet_write(fpm_globals.send_config_pipe[1], &writeval, sizeof(writeval));
close(fpm_globals.send_config_pipe[1]);
}
return FPM_EXIT_CONFIG;
exit_status = FPM_EXIT_CONFIG;
goto out;
} else if (ret == FPM_INIT_EXIT_OK) {
exit_status = FPM_EXIT_OK;
goto out;
}

if (fpm_globals.send_config_pipe[1]) {
Expand Down