Skip to content

Commit 23250d5

Browse files
author
fat
committed
Fixed exit at FPM startup on fpm_resources_prepare
git-svn-id: http://svn.php.net/repository/php/php-src/trunk@312260 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 58c65d2 commit 23250d5

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

sapi/fpm/fpm/fpm.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,16 @@ int fpm_run(int *max_requests) /* {{{ */
9090
if (!is_parent) {
9191
goto run_child;
9292
}
93+
94+
/* handle error */
95+
if (is_parent == 2) {
96+
fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET);
97+
fpm_event_loop(1);
98+
}
9399
}
94100

95101
/* run event loop forever */
96-
fpm_event_loop();
102+
fpm_event_loop(0);
97103

98104
run_child: /* only workers reach this point */
99105

sapi/fpm/fpm/fpm_children.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ static void fpm_parent_resources_use(struct fpm_child_s *child) /* {{{ */
350350

351351
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug) /* {{{ */
352352
{
353-
int enough = 0;
354353
pid_t pid;
355354
struct fpm_child_s *child;
356355
int max;
@@ -365,12 +364,11 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
365364
max = wp->config->pm_max_children;
366365
}
367366

368-
while (!enough && fpm_pctl_can_spawn_children() && wp->running_children < max) {
367+
while (fpm_pctl_can_spawn_children() && wp->running_children < max) {
369368
child = fpm_resources_prepare(wp);
370369

371370
if (!child) {
372-
enough = 1;
373-
break;
371+
return 2;
374372
}
375373

376374
pid = fork();
@@ -385,11 +383,9 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
385383

386384
case -1 :
387385
zlog(ZLOG_SYSERROR, "fork() failed");
388-
enough = 1;
389386

390387
fpm_resources_discard(child);
391-
392-
break; /* dont try any more on error */
388+
return 2;
393389

394390
default :
395391
child->pid = pid;

sapi/fpm/fpm/fpm_events.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ int fpm_event_init_main() /* {{{ */
235235
}
236236
/* }}} */
237237

238-
void fpm_event_loop() /* {{{ */
238+
void fpm_event_loop(int err) /* {{{ */
239239
{
240240
static struct fpm_event_s signal_fd_event;
241241

@@ -249,9 +249,12 @@ void fpm_event_loop() /* {{{ */
249249

250250
/* add timers */
251251
fpm_pctl_heartbeat(NULL, 0, NULL);
252-
fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL);
253252

254-
zlog(ZLOG_NOTICE, "ready to handle connections");
253+
if (!err) {
254+
fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL);
255+
256+
zlog(ZLOG_NOTICE, "ready to handle connections");
257+
}
255258

256259
while (1) {
257260
struct fpm_event_queue_s *q, *q2;

sapi/fpm/fpm/fpm_events.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct fpm_event_s {
2222
short which; /* type of event */
2323
};
2424

25-
void fpm_event_loop();
25+
void fpm_event_loop(int err);
2626
void fpm_event_fire(struct fpm_event_s *ev);
2727
int fpm_event_init_main();
2828
int fpm_event_set(struct fpm_event_s *ev, int fd, int flags, void (*callback)(struct fpm_event_s *, short, void *), void *arg);

0 commit comments

Comments
 (0)