Skip to content

Commit 2c5c0a0

Browse files
committed
Convert return values to bool in fpm_scoreboard.c
The return value was always one of two values.
1 parent 995f4b8 commit 2c5c0a0

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

sapi/fpm/fpm/fpm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int t
5757
0 > fpm_stdio_init_main() ||
5858
!fpm_conf_init_main(test_conf, force_daemon) ||
5959
0 > fpm_unix_init_main() ||
60-
0 > fpm_scoreboard_init_main() ||
60+
!fpm_scoreboard_init_main() ||
6161
!fpm_pctl_init_main() ||
6262
!fpm_env_init_main() ||
6363
0 > fpm_signals_init_main() ||

sapi/fpm/fpm/fpm_children.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static struct fpm_child_s *fpm_resources_prepare(struct fpm_worker_pool_s *wp) /
320320
return 0;
321321
}
322322

323-
if (0 > fpm_scoreboard_proc_alloc(c)) {
323+
if (!fpm_scoreboard_proc_alloc(c)) {
324324
fpm_stdio_discard_pipes(c);
325325
fpm_child_free(c);
326326
return 0;

sapi/fpm/fpm/fpm_scoreboard.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static float fpm_scoreboard_tick;
2121
#endif
2222

2323

24-
int fpm_scoreboard_init_main(void)
24+
bool fpm_scoreboard_init_main(void)
2525
{
2626
struct fpm_worker_pool_s *wp;
2727

@@ -45,19 +45,19 @@ int fpm_scoreboard_init_main(void)
4545

4646
if (wp->config->pm_max_children < 1) {
4747
zlog(ZLOG_ERROR, "[pool %s] Unable to create scoreboard SHM because max_client is not set", wp->config->name);
48-
return -1;
48+
return false;
4949
}
5050

5151
if (wp->scoreboard) {
5252
zlog(ZLOG_ERROR, "[pool %s] Unable to create scoreboard SHM because it already exists", wp->config->name);
53-
return -1;
53+
return false;
5454
}
5555

5656
scoreboard_procs_size = sizeof(struct fpm_scoreboard_proc_s) * wp->config->pm_max_children;
5757
shm_mem = fpm_shm_alloc(sizeof(struct fpm_scoreboard_s) + scoreboard_procs_size);
5858

5959
if (!shm_mem) {
60-
return -1;
60+
return false;
6161
}
6262
wp->scoreboard = shm_mem;
6363
wp->scoreboard->pm = wp->config->pm;
@@ -70,7 +70,7 @@ int fpm_scoreboard_init_main(void)
7070
wp->scoreboard->shared = wp->shared->scoreboard;
7171
}
7272
}
73-
return 0;
73+
return true;
7474
}
7575

7676
static struct fpm_scoreboard_s *fpm_scoreboard_get_for_update(struct fpm_scoreboard_s *scoreboard) /* {{{ */
@@ -392,15 +392,15 @@ void fpm_scoreboard_proc_free(struct fpm_child_s *child) /* {{{ */
392392
}
393393
/* }}} */
394394

395-
int fpm_scoreboard_proc_alloc(struct fpm_child_s *child) /* {{{ */
395+
bool fpm_scoreboard_proc_alloc(struct fpm_child_s *child) /* {{{ */
396396
{
397397
int i = -1;
398398
struct fpm_worker_pool_s *wp = child->wp;
399399
struct fpm_scoreboard_s *scoreboard = wp->scoreboard;
400400
int nprocs = wp->config->pm_max_children;
401401

402402
if (!scoreboard) {
403-
return -1;
403+
return false;
404404
}
405405

406406
/* first try the slot which is supposed to be free */
@@ -422,7 +422,7 @@ int fpm_scoreboard_proc_alloc(struct fpm_child_s *child) /* {{{ */
422422
/* no free slot */
423423
if (i < 0 || i >= nprocs) {
424424
zlog(ZLOG_ERROR, "[pool %s] no free scoreboard slot", scoreboard->pool);
425-
return -1;
425+
return false;
426426
}
427427

428428
scoreboard->procs[i].used = 1;
@@ -435,7 +435,7 @@ int fpm_scoreboard_proc_alloc(struct fpm_child_s *child) /* {{{ */
435435
scoreboard->free_proc = i + 1;
436436
}
437437

438-
return 0;
438+
return true;
439439
}
440440
/* }}} */
441441

sapi/fpm/fpm/fpm_scoreboard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ struct fpm_scoreboard_s {
7070
struct fpm_scoreboard_proc_s procs[];
7171
};
7272

73-
int fpm_scoreboard_init_main(void);
74-
int fpm_scoreboard_init_child(struct fpm_worker_pool_s *wp);
73+
bool fpm_scoreboard_init_main(void);
74+
int fpm_scoreboard_init_child(struct fpm_worker_pool_s *wp); /* TODO Define this function? */
7575

7676
void fpm_scoreboard_update_begin(struct fpm_scoreboard_s *scoreboard);
7777
void fpm_scoreboard_update_commit(int idle, int active, int lq, int lq_len, int requests, int max_children_reached, int slow_rq, int action, struct fpm_scoreboard_s *scoreboard);
@@ -91,7 +91,7 @@ void fpm_scoreboard_free(struct fpm_worker_pool_s *wp);
9191
void fpm_scoreboard_child_use(struct fpm_child_s *child, pid_t pid);
9292

9393
void fpm_scoreboard_proc_free(struct fpm_child_s *child);
94-
int fpm_scoreboard_proc_alloc(struct fpm_child_s *child);
94+
bool fpm_scoreboard_proc_alloc(struct fpm_child_s *child);
9595

9696
struct fpm_scoreboard_s *fpm_scoreboard_copy(struct fpm_scoreboard_s *scoreboard, int copy_procs);
9797
void fpm_scoreboard_free_copy(struct fpm_scoreboard_s *scoreboard);

0 commit comments

Comments
 (0)