fat Sat, 18 Jun 2011 16:15:15 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=312260
Log:
Fixed exit at FPM startup on fpm_resources_prepare
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.c
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.h
U php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm.c
U php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_children.c
U php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.c
U php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.h
U php/php-src/trunk/sapi/fpm/fpm/fpm.c
U php/php-src/trunk/sapi/fpm/fpm/fpm_children.c
U php/php-src/trunk/sapi/fpm/fpm/fpm_events.c
U php/php-src/trunk/sapi/fpm/fpm/fpm_events.h
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-06-18 16:15:15 UTC (rev 312260)
@@ -174,6 +174,7 @@
- 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
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -90,10 +90,16 @@
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 */
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -350,7 +350,6 @@
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 @@
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,12 +383,10 @@
case -1 :
zlog(ZLOG_SYSERROR, "fork() failed");
- enough = 1;
fpm_resources_discard(child);
+ return 2;
- break; /* dont try any more on error */
-
default :
child->pid = pid;
fpm_clock_get(&child->started);
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -235,7 +235,7 @@
}
/* }}} */
-void fpm_event_loop() /* {{{ */
+void fpm_event_loop(int err) /* {{{ */
{
static struct fpm_event_s signal_fd_event;
@@ -249,10 +249,13 @@
/* 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;
struct timeval ms;
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.h
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.h 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.h 2011-06-18 16:15:15 UTC (rev 312260)
@@ -22,7 +22,7 @@
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);
Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm.c
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -90,10 +90,16 @@
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 */
Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_children.c
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_children.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_children.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -350,7 +350,6 @@
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 @@
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,12 +383,10 @@
case -1 :
zlog(ZLOG_SYSERROR, "fork() failed");
- enough = 1;
fpm_resources_discard(child);
+ return 2;
- break; /* dont try any more on error */
-
default :
child->pid = pid;
fpm_clock_get(&child->started);
Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.c
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -235,7 +235,7 @@
}
/* }}} */
-void fpm_event_loop() /* {{{ */
+void fpm_event_loop(int err) /* {{{ */
{
static struct fpm_event_s signal_fd_event;
@@ -249,10 +249,13 @@
/* 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;
struct timeval ms;
Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.h
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.h 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_events.h 2011-06-18 16:15:15 UTC (rev 312260)
@@ -22,7 +22,7 @@
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);
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -90,10 +90,16 @@
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 */
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_children.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_children.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_children.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -350,7 +350,6 @@
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 @@
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,12 +383,10 @@
case -1 :
zlog(ZLOG_SYSERROR, "fork() failed");
- enough = 1;
fpm_resources_discard(child);
+ return 2;
- break; /* dont try any more on error */
-
default :
child->pid = pid;
fpm_clock_get(&child->started);
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_events.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_events.c 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_events.c 2011-06-18 16:15:15 UTC (rev 312260)
@@ -235,7 +235,7 @@
}
/* }}} */
-void fpm_event_loop() /* {{{ */
+void fpm_event_loop(int err) /* {{{ */
{
static struct fpm_event_s signal_fd_event;
@@ -249,10 +249,13 @@
/* 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;
struct timeval ms;
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_events.h
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_events.h 2011-06-18 16:05:56 UTC (rev 312259)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_events.h 2011-06-18 16:15:15 UTC (rev 312260)
@@ -22,7 +22,7 @@
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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php