]> granicus.if.org Git - php/commitdiff
Fixed exit at FPM startup on fpm_resources_prepare
authorJérôme Loyet <fat@php.net>
Sat, 18 Jun 2011 16:15:15 +0000 (16:15 +0000)
committerJérôme Loyet <fat@php.net>
Sat, 18 Jun 2011 16:15:15 +0000 (16:15 +0000)
NEWS
sapi/fpm/fpm/fpm.c
sapi/fpm/fpm/fpm_children.c
sapi/fpm/fpm/fpm_events.c
sapi/fpm/fpm/fpm_events.h

diff --git a/NEWS b/NEWS
index 27301f467b056bbfd1025e76572af02f3190f2a5..78f7bd7bd0385d78d1df6b4c4a4464b38dbeb697 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -174,6 +174,7 @@ PHP                                                                        NEWS
 - PHP-FPM SAPI:
   . Added xml format to the status page. (fat)
   . Remove timestamp in logs written by children processes. (fat)
+  . Fixed exit at FPM startup on fpm_resources_prepare() errors. (fat)
 
 - Reflection extension:
   . Fixed bug #54347 (reflection_extension does not lowercase module function
index 0cfaabd414b125bd407076efdb7892251a8e1baa..e3fa3e3bd694b3192821f06db6e5368dc9f737a3 100644 (file)
@@ -90,10 +90,16 @@ int fpm_run(int *max_requests) /* {{{ */
                if (!is_parent) {
                        goto run_child;
                }
+
+               /* handle error */
+               if (is_parent == 2) {
+                       fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET);
+                       fpm_event_loop(1);
+               }
        }
 
        /* run event loop forever */
-       fpm_event_loop();
+       fpm_event_loop(0);
 
 run_child: /* only workers reach this point */
 
index 499ad08e8f2afdc414ea1ebe8ded4646dc08cfab..476d5523deac518390d6c5898a3381ef66b1713d 100644 (file)
@@ -350,7 +350,6 @@ static void fpm_parent_resources_use(struct fpm_child_s *child) /* {{{ */
 
 int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug) /* {{{ */
 {
-       int enough = 0;
        pid_t pid;
        struct fpm_child_s *child;
        int max;
@@ -365,12 +364,11 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
                max = wp->config->pm_max_children;
        }
 
-       while (!enough && fpm_pctl_can_spawn_children() && wp->running_children < max) {
+       while (fpm_pctl_can_spawn_children() && wp->running_children < max) {
                child = fpm_resources_prepare(wp);
 
                if (!child) {
-                       enough = 1;
-                       break;
+                       return 2;
                }
 
                pid = fork();
@@ -385,11 +383,9 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
 
                        case -1 :
                                zlog(ZLOG_SYSERROR, "fork() failed");
-                               enough = 1;
 
                                fpm_resources_discard(child);
-
-                               break; /* dont try any more on error */
+                               return 2;
 
                        default :
                                child->pid = pid;
index 66ff393e2f059ef07cc795743addb7b70da2f424..2bb4b94c00d57eb8cfe783e2edb1dc0eace4f50c 100644 (file)
@@ -235,7 +235,7 @@ int fpm_event_init_main() /* {{{ */
 }
 /* }}} */
 
-void fpm_event_loop() /* {{{ */
+void fpm_event_loop(int err) /* {{{ */
 {
        static struct fpm_event_s signal_fd_event;
 
@@ -249,9 +249,12 @@ void fpm_event_loop() /* {{{ */
 
        /* add timers */
        fpm_pctl_heartbeat(NULL, 0, NULL);
-       fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL);
 
-       zlog(ZLOG_NOTICE, "ready to handle connections");
+       if (!err) {
+               fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL);
+
+               zlog(ZLOG_NOTICE, "ready to handle connections");
+       }
 
        while (1) {
                struct fpm_event_queue_s *q, *q2;
index bec13ba5e7665b2cfccf905934825c4e9f6bff2e..586b24283565fc83ef046fd7df85841c578343e4 100644 (file)
@@ -22,7 +22,7 @@ struct fpm_event_s {
        short which;              /* type of event */
 };
 
-void fpm_event_loop();
+void fpm_event_loop(int err);
 void fpm_event_fire(struct fpm_event_s *ev);
 int fpm_event_init_main();
 int fpm_event_set(struct fpm_event_s *ev, int fd, int flags, void (*callback)(struct fpm_event_s *, short, void *), void *arg);