Skip to content

sapi/fpm: change lots of return types to zend_result #10662

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
26 changes: 13 additions & 13 deletions sapi/fpm/fpm/fpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ enum fpm_init_return_status fpm_init(int argc, char **argv, char *config, char *
fpm_globals.run_as_root = run_as_root;
fpm_globals.force_stderr = force_stderr;

if (0 > fpm_php_init_main() ||
0 > fpm_stdio_init_main() ||
0 > fpm_conf_init_main(test_conf, force_daemon) ||
0 > fpm_unix_init_main() ||
0 > fpm_scoreboard_init_main() ||
0 > fpm_pctl_init_main() ||
0 > fpm_env_init_main() ||
0 > fpm_signals_init_main() ||
0 > fpm_children_init_main() ||
0 > fpm_sockets_init_main() ||
0 > fpm_worker_pool_init_main() ||
0 > fpm_event_init_main()) {
if (fpm_php_init_main() != SUCCESS ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note bukka usually prefers when operands are reversed :-) but I ll leave up to him to decide on this.

fpm_stdio_init_main() != SUCCESS ||
fpm_conf_init_main(test_conf, force_daemon) != SUCCESS ||
fpm_unix_init_main() != SUCCESS ||
fpm_scoreboard_init_main() != SUCCESS ||
fpm_pctl_init_main() != SUCCESS||
fpm_env_init_main() != SUCCESS ||
fpm_signals_init_main() != SUCCESS ||
fpm_children_init_main() != SUCCESS ||
fpm_sockets_init_main() != SUCCESS ||
fpm_worker_pool_init_main() != SUCCESS ||
fpm_event_init_main() != SUCCESS) {

if (fpm_globals.test_successful) {
return FPM_INIT_EXIT_OK;
Expand All @@ -74,7 +74,7 @@ enum fpm_init_return_status fpm_init(int argc, char **argv, char *config, char *
}
}

if (0 > fpm_conf_write_pid()) {
if (fpm_conf_write_pid() != SUCCESS) {
zlog(ZLOG_ERROR, "FPM initialization failed");
return FPM_INIT_ERROR;
}
Expand Down
36 changes: 16 additions & 20 deletions sapi/fpm/fpm/fpm_children.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */
fpm_globals.max_requests = wp->config->pm_max_requests;
fpm_globals.listening_socket = dup(wp->listening_socket);

if (0 > fpm_stdio_init_child(wp) ||
0 > fpm_log_init_child(wp) ||
0 > fpm_status_init_child(wp) ||
0 > fpm_unix_init_child(wp) ||
0 > fpm_signals_init_child() ||
0 > fpm_env_init_child(wp) ||
0 > fpm_php_init_child(wp)) {
if (fpm_stdio_init_child(wp) != SUCCESS ||
fpm_log_init_child(wp) != SUCCESS ||
fpm_status_init_child(wp) != SUCCESS ||
fpm_unix_init_child(wp) != SUCCESS ||
fpm_signals_init_child() != SUCCESS ||
fpm_env_init_child(wp) != SUCCESS ||
fpm_php_init_child(wp) != SUCCESS) {

zlog(ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name);
exit(FPM_EXIT_SOFTWARE);
Expand Down Expand Up @@ -313,21 +313,21 @@ static struct fpm_child_s *fpm_resources_prepare(struct fpm_worker_pool_s *wp) /

if (!c) {
zlog(ZLOG_ERROR, "[pool %s] unable to malloc new child", wp->config->name);
return 0;
return NULL;
}

c->wp = wp;
c->fd_stdout = -1; c->fd_stderr = -1;

if (0 > fpm_stdio_prepare_pipes(c)) {
if (fpm_stdio_prepare_pipes(c) != SUCCESS) {
fpm_child_free(c);
return 0;
return NULL;
}

if (0 > fpm_scoreboard_proc_alloc(c)) {
if (fpm_scoreboard_proc_alloc(c) != SUCCESS) {
fpm_stdio_discard_pipes(c);
fpm_child_free(c);
return 0;
return NULL;
}

return c;
Expand Down Expand Up @@ -405,7 +405,7 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
}

zlog(ZLOG_DEBUG, "blocking signals before child birth");
if (0 > fpm_signals_child_block()) {
if (fpm_signals_child_block() != SUCCESS) {
zlog(ZLOG_WARNING, "child may miss signals");
}

Expand Down Expand Up @@ -472,23 +472,19 @@ int fpm_children_create_initial(struct fpm_worker_pool_s *wp) /* {{{ */
}
/* }}} */

int fpm_children_init_main(void)
zend_result fpm_children_init_main(void)
{
if (fpm_global_config.emergency_restart_threshold &&
fpm_global_config.emergency_restart_interval) {

last_faults = malloc(sizeof(time_t) * fpm_global_config.emergency_restart_threshold);

if (!last_faults) {
return -1;
return FAILURE;
}

memset(last_faults, 0, sizeof(time_t) * fpm_global_config.emergency_restart_threshold);
}

if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_children_cleanup, 0)) {
return -1;
}

return 0;
return fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_children_cleanup, 0);
}
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/fpm_children.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct fpm_child_s;
int fpm_children_create_initial(struct fpm_worker_pool_s *wp);
int fpm_children_free(struct fpm_child_s *child);
void fpm_children_bury(void);
int fpm_children_init_main(void);
zend_result fpm_children_init_main(void);
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug);
struct fpm_child_s *fpm_child_find(pid_t pid);

Expand Down
6 changes: 3 additions & 3 deletions sapi/fpm/fpm/fpm_cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ struct cleanup_s {

static struct fpm_array_s cleanups = { .sz = sizeof(struct cleanup_s) };

int fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *arg) /* {{{ */
zend_result fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *arg) /* {{{ */
{
struct cleanup_s *c;

c = fpm_array_push(&cleanups);

if (!c) {
return -1;
return FAILURE;
}

c->type = type;
c->cleanup = cleanup;
c->arg = arg;

return 0;
return SUCCESS;
}
/* }}} */

Expand Down
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/fpm_cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef FPM_CLEANUP_H
#define FPM_CLEANUP_H 1

int fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *);
zend_result fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *);
void fpm_cleanups_run(int type);

enum {
Expand Down
34 changes: 17 additions & 17 deletions sapi/fpm/fpm/fpm_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

static int monotonic_works;

int fpm_clock_init(void)
zend_result fpm_clock_init(void)
{
struct timespec ts;

Expand All @@ -25,25 +25,25 @@ int fpm_clock_init(void)
monotonic_works = 1;
}

return 0;
return SUCCESS;
}

int fpm_clock_get(struct timeval *tv) /* {{{ */
zend_result fpm_clock_get(struct timeval *tv) /* {{{ */
{
if (monotonic_works) {
struct timespec ts;

if (0 > clock_gettime(CLOCK_MONOTONIC, &ts)) {
zlog(ZLOG_SYSERROR, "clock_gettime() failed");
return -1;
return FAILURE;
}

tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / 1000;
return 0;
return SUCCESS;
}

return gettimeofday(tv, 0);
return gettimeofday(tv, 0) == 0 ? SUCCESS : FAILURE;
}
/* }}} */

Expand All @@ -58,7 +58,7 @@ static clock_serv_t mach_clock;

/* this code borrowed from here: http://lists.apple.com/archives/Darwin-development/2002/Mar/msg00746.html */
/* mach_clock also should be re-initialized in child process after fork */
int fpm_clock_init(void)
zend_result fpm_clock_init(void)
{
kern_return_t ret;
mach_timespec_t aTime;
Expand All @@ -67,21 +67,21 @@ int fpm_clock_init(void)

if (ret != KERN_SUCCESS) {
zlog(ZLOG_ERROR, "host_get_clock_service() failed: %s", mach_error_string(ret));
return -1;
return FAILURE;
}

/* test if it works */
ret = clock_get_time(mach_clock, &aTime);

if (ret != KERN_SUCCESS) {
zlog(ZLOG_ERROR, "clock_get_time() failed: %s", mach_error_string(ret));
return -1;
return FAILURE;
}

return 0;
return SUCCESS;
}

int fpm_clock_get(struct timeval *tv) /* {{{ */
zend_result fpm_clock_get(struct timeval *tv) /* {{{ */
{
kern_return_t ret;
mach_timespec_t aTime;
Expand All @@ -90,26 +90,26 @@ int fpm_clock_get(struct timeval *tv) /* {{{ */

if (ret != KERN_SUCCESS) {
zlog(ZLOG_ERROR, "clock_get_time() failed: %s", mach_error_string(ret));
return -1;
return FAILURE;
}

tv->tv_sec = aTime.tv_sec;
tv->tv_usec = aTime.tv_nsec / 1000;

return 0;
return SUCCESS;
}
/* }}} */

#else /* no clock */

int fpm_clock_init(void)
zend_result fpm_clock_init(void)
{
return 0;
return SUCCESS;
}

int fpm_clock_get(struct timeval *tv) /* {{{ */
zend_result fpm_clock_get(struct timeval *tv) /* {{{ */
{
return gettimeofday(tv, 0);
return gettimeofday(tv, 0) == 0 ? SUCCESS : FAILURE;
}
/* }}} */

Expand Down
6 changes: 4 additions & 2 deletions sapi/fpm/fpm/fpm_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#ifndef FPM_CLOCK_H
#define FPM_CLOCK_H 1

#include "zend_result.h"

#include <sys/time.h>

int fpm_clock_init(void);
int fpm_clock_get(struct timeval *tv);
zend_result fpm_clock_init(void);
zend_result fpm_clock_get(struct timeval *tv);

#endif
Loading