Skip to content

Commit f31be66

Browse files
committed
sapi/fpm: change lots of return types to zend_result
More of php#10622
1 parent f4313a8 commit f31be66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+580
-587
lines changed

sapi/fpm/fpm/fpm.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ enum fpm_init_return_status fpm_init(int argc, char **argv, char *config, char *
5353
fpm_globals.run_as_root = run_as_root;
5454
fpm_globals.force_stderr = force_stderr;
5555

56-
if (0 > fpm_php_init_main() ||
57-
0 > fpm_stdio_init_main() ||
58-
0 > fpm_conf_init_main(test_conf, force_daemon) ||
59-
0 > fpm_unix_init_main() ||
60-
0 > fpm_scoreboard_init_main() ||
61-
0 > fpm_pctl_init_main() ||
62-
0 > fpm_env_init_main() ||
63-
0 > fpm_signals_init_main() ||
64-
0 > fpm_children_init_main() ||
65-
0 > fpm_sockets_init_main() ||
66-
0 > fpm_worker_pool_init_main() ||
67-
0 > fpm_event_init_main()) {
56+
if (fpm_php_init_main() != SUCCESS ||
57+
fpm_stdio_init_main() != SUCCESS ||
58+
fpm_conf_init_main(test_conf, force_daemon) != SUCCESS ||
59+
fpm_unix_init_main() != SUCCESS ||
60+
fpm_scoreboard_init_main() != SUCCESS ||
61+
fpm_pctl_init_main() != SUCCESS||
62+
fpm_env_init_main() != SUCCESS ||
63+
fpm_signals_init_main() != SUCCESS ||
64+
fpm_children_init_main() != SUCCESS ||
65+
fpm_sockets_init_main() != SUCCESS ||
66+
fpm_worker_pool_init_main() != SUCCESS ||
67+
fpm_event_init_main() != SUCCESS) {
6868

6969
if (fpm_globals.test_successful) {
7070
return FPM_INIT_EXIT_OK;
@@ -74,7 +74,7 @@ enum fpm_init_return_status fpm_init(int argc, char **argv, char *config, char *
7474
}
7575
}
7676

77-
if (0 > fpm_conf_write_pid()) {
77+
if (fpm_conf_write_pid() != SUCCESS) {
7878
zlog(ZLOG_ERROR, "FPM initialization failed");
7979
return FPM_INIT_ERROR;
8080
}

sapi/fpm/fpm/fpm_children.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */
149149
fpm_globals.max_requests = wp->config->pm_max_requests;
150150
fpm_globals.listening_socket = dup(wp->listening_socket);
151151

152-
if (0 > fpm_stdio_init_child(wp) ||
153-
0 > fpm_log_init_child(wp) ||
154-
0 > fpm_status_init_child(wp) ||
155-
0 > fpm_unix_init_child(wp) ||
156-
0 > fpm_signals_init_child() ||
157-
0 > fpm_env_init_child(wp) ||
158-
0 > fpm_php_init_child(wp)) {
152+
if (fpm_stdio_init_child(wp) != SUCCESS ||
153+
fpm_log_init_child(wp) != SUCCESS ||
154+
fpm_status_init_child(wp) != SUCCESS ||
155+
fpm_unix_init_child(wp) != SUCCESS ||
156+
fpm_signals_init_child() != SUCCESS ||
157+
fpm_env_init_child(wp) != SUCCESS ||
158+
fpm_php_init_child(wp) != SUCCESS) {
159159

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

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

319319
c->wp = wp;
320320
c->fd_stdout = -1; c->fd_stderr = -1;
321321

322-
if (0 > fpm_stdio_prepare_pipes(c)) {
322+
if (fpm_stdio_prepare_pipes(c) != SUCCESS) {
323323
fpm_child_free(c);
324-
return 0;
324+
return NULL;
325325
}
326326

327-
if (0 > fpm_scoreboard_proc_alloc(c)) {
327+
if (fpm_scoreboard_proc_alloc(c) != SUCCESS) {
328328
fpm_stdio_discard_pipes(c);
329329
fpm_child_free(c);
330-
return 0;
330+
return NULL;
331331
}
332332

333333
return c;
@@ -405,7 +405,7 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
405405
}
406406

407407
zlog(ZLOG_DEBUG, "blocking signals before child birth");
408-
if (0 > fpm_signals_child_block()) {
408+
if (fpm_signals_child_block() != SUCCESS) {
409409
zlog(ZLOG_WARNING, "child may miss signals");
410410
}
411411

@@ -472,23 +472,19 @@ int fpm_children_create_initial(struct fpm_worker_pool_s *wp) /* {{{ */
472472
}
473473
/* }}} */
474474

475-
int fpm_children_init_main(void)
475+
zend_result fpm_children_init_main(void)
476476
{
477477
if (fpm_global_config.emergency_restart_threshold &&
478478
fpm_global_config.emergency_restart_interval) {
479479

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

482482
if (!last_faults) {
483-
return -1;
483+
return FAILURE;
484484
}
485485

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

489-
if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_children_cleanup, 0)) {
490-
return -1;
491-
}
492-
493-
return 0;
489+
return fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_children_cleanup, 0);
494490
}

sapi/fpm/fpm/fpm_children.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct fpm_child_s;
1515
int fpm_children_create_initial(struct fpm_worker_pool_s *wp);
1616
int fpm_children_free(struct fpm_child_s *child);
1717
void fpm_children_bury(void);
18-
int fpm_children_init_main(void);
18+
zend_result fpm_children_init_main(void);
1919
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug);
2020
struct fpm_child_s *fpm_child_find(pid_t pid);
2121

sapi/fpm/fpm/fpm_cleanup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ struct cleanup_s {
1515

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

18-
int fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *arg) /* {{{ */
18+
zend_result fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *arg) /* {{{ */
1919
{
2020
struct cleanup_s *c;
2121

2222
c = fpm_array_push(&cleanups);
2323

2424
if (!c) {
25-
return -1;
25+
return FAILURE;
2626
}
2727

2828
c->type = type;
2929
c->cleanup = cleanup;
3030
c->arg = arg;
3131

32-
return 0;
32+
return SUCCESS;
3333
}
3434
/* }}} */
3535

sapi/fpm/fpm/fpm_cleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#ifndef FPM_CLEANUP_H
44
#define FPM_CLEANUP_H 1
55

6-
int fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *);
6+
zend_result fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *);
77
void fpm_cleanups_run(int type);
88

99
enum {

sapi/fpm/fpm/fpm_clock.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
static int monotonic_works;
1717

18-
int fpm_clock_init(void)
18+
zend_result fpm_clock_init(void)
1919
{
2020
struct timespec ts;
2121

@@ -25,25 +25,25 @@ int fpm_clock_init(void)
2525
monotonic_works = 1;
2626
}
2727

28-
return 0;
28+
return SUCCESS;
2929
}
3030

31-
int fpm_clock_get(struct timeval *tv) /* {{{ */
31+
zend_result fpm_clock_get(struct timeval *tv) /* {{{ */
3232
{
3333
if (monotonic_works) {
3434
struct timespec ts;
3535

3636
if (0 > clock_gettime(CLOCK_MONOTONIC, &ts)) {
3737
zlog(ZLOG_SYSERROR, "clock_gettime() failed");
38-
return -1;
38+
return FAILURE;
3939
}
4040

4141
tv->tv_sec = ts.tv_sec;
4242
tv->tv_usec = ts.tv_nsec / 1000;
43-
return 0;
43+
return SUCCESS;
4444
}
4545

46-
return gettimeofday(tv, 0);
46+
return gettimeofday(tv, 0) == 0 ? SUCCESS : FAILURE;
4747
}
4848
/* }}} */
4949

@@ -58,7 +58,7 @@ static clock_serv_t mach_clock;
5858

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

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

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

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

81-
return 0;
81+
return SUCCESS;
8282
}
8383

84-
int fpm_clock_get(struct timeval *tv) /* {{{ */
84+
zend_result fpm_clock_get(struct timeval *tv) /* {{{ */
8585
{
8686
kern_return_t ret;
8787
mach_timespec_t aTime;
@@ -90,26 +90,26 @@ int fpm_clock_get(struct timeval *tv) /* {{{ */
9090

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

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

99-
return 0;
99+
return SUCCESS;
100100
}
101101
/* }}} */
102102

103103
#else /* no clock */
104104

105-
int fpm_clock_init(void)
105+
zend_result fpm_clock_init(void)
106106
{
107-
return 0;
107+
return SUCCESS;
108108
}
109109

110-
int fpm_clock_get(struct timeval *tv) /* {{{ */
110+
zend_result fpm_clock_get(struct timeval *tv) /* {{{ */
111111
{
112-
return gettimeofday(tv, 0);
112+
return gettimeofday(tv, 0) == 0 ? SUCCESS : FAILURE;
113113
}
114114
/* }}} */
115115

sapi/fpm/fpm/fpm_clock.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
#ifndef FPM_CLOCK_H
44
#define FPM_CLOCK_H 1
55

6+
#include "zend_result.h"
7+
68
#include <sys/time.h>
79

8-
int fpm_clock_init(void);
9-
int fpm_clock_get(struct timeval *tv);
10+
zend_result fpm_clock_init(void);
11+
zend_result fpm_clock_get(struct timeval *tv);
1012

1113
#endif

0 commit comments

Comments
 (0)