- Fixed bug #55526 (Heartbeat causes a lot of unnecessary events)

This commit is contained in:
Jérôme Loyet 2011-10-09 15:12:26 +00:00
parent 3982cda83b
commit f58cf75068
7 changed files with 21 additions and 5 deletions

1
NEWS
View File

@ -75,6 +75,7 @@ PHP NEWS
. Fixed bug #53872 (internal corruption of phar). (Hannes) . Fixed bug #53872 (internal corruption of phar). (Hannes)
- PHP-FPM SAPI: - PHP-FPM SAPI:
. Fixed bug #55526 (Heartbeat causes a lot of unnecessary events). (fat)
. Fixed bug #55533 (The -d parameter doesn't work). (fat) . Fixed bug #55533 (The -d parameter doesn't work). (fat)
. Implemented FR #52569 (Add the "ondemand" process-manager . Implemented FR #52569 (Add the "ondemand" process-manager
to allow zero children). (fat) to allow zero children). (fat)

View File

@ -36,7 +36,8 @@ struct fpm_globals_s fpm_globals = {
.listening_socket = 0, .listening_socket = 0,
.max_requests = 0, .max_requests = 0,
.is_child = 0, .is_child = 0,
.test_successful = 0 .test_successful = 0,
.heartbeat = 0
}; };
int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf) /* {{{ */ int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf) /* {{{ */

View File

@ -24,6 +24,7 @@ struct fpm_globals_s {
int max_requests; /* for this child */ int max_requests; /* for this child */
int is_child; int is_child;
int test_successful; int test_successful;
int heartbeat;
}; };
extern struct fpm_globals_s fpm_globals; extern struct fpm_globals_s fpm_globals;

View File

@ -878,6 +878,10 @@ static int fpm_conf_process_all_pools() /* {{{ */
} }
} }
if (wp->config->request_terminate_timeout) {
fpm_globals.heartbeat = fpm_globals.heartbeat ? MIN(fpm_globals.heartbeat, (wp->config->request_terminate_timeout * 1000) / 3) : (wp->config->request_terminate_timeout * 1000) / 3;
}
/* slowlog */ /* slowlog */
if (wp->config->slowlog && *wp->config->slowlog) { if (wp->config->slowlog && *wp->config->slowlog) {
fpm_evaluate_full_path(&wp->config->slowlog, wp, NULL, 0); fpm_evaluate_full_path(&wp->config->slowlog, wp, NULL, 0);
@ -912,6 +916,8 @@ static int fpm_conf_process_all_pools() /* {{{ */
} }
close(fd); close(fd);
} }
fpm_globals.heartbeat = fpm_globals.heartbeat ? MIN(fpm_globals.heartbeat, (wp->config->request_slowlog_timeout * 1000) / 3) : (wp->config->request_slowlog_timeout * 1000) / 3;
} }
/* chroot */ /* chroot */

View File

@ -350,7 +350,9 @@ void fpm_event_loop(int err) /* {{{ */
fpm_event_add(&signal_fd_event, 0); fpm_event_add(&signal_fd_event, 0);
/* add timers */ /* add timers */
if (fpm_globals.heartbeat > 0) {
fpm_pctl_heartbeat(NULL, 0, NULL); fpm_pctl_heartbeat(NULL, 0, NULL);
}
if (!err) { if (!err) {
fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL); fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL);

View File

@ -453,9 +453,13 @@ void fpm_pctl_heartbeat(struct fpm_event_s *ev, short which, void *arg) /* {{{ *
return; return;
} }
/* ensure heartbeat is not lower than FPM_PCTL_MIN_HEARTBEAT */
fpm_globals.heartbeat = MAX(fpm_globals.heartbeat, FPM_PCTL_MIN_HEARTBEAT);
/* first call without setting to initialize the timer */ /* first call without setting to initialize the timer */
zlog(ZLOG_DEBUG, "heartbeat have been set up with a timeout of %dms", fpm_globals.heartbeat);
fpm_event_set_timer(&heartbeat, FPM_EV_PERSIST, &fpm_pctl_heartbeat, NULL); fpm_event_set_timer(&heartbeat, FPM_EV_PERSIST, &fpm_pctl_heartbeat, NULL);
fpm_event_add(&heartbeat, FPM_PCTL_HEARTBEAT); fpm_event_add(&heartbeat, fpm_globals.heartbeat);
} }
/* }}} */ /* }}} */

View File

@ -11,8 +11,9 @@
#define FPM_MAX_SPAWN_RATE (32) #define FPM_MAX_SPAWN_RATE (32)
/* 1s (in ms) heartbeat for idle server maintenance */ /* 1s (in ms) heartbeat for idle server maintenance */
#define FPM_IDLE_SERVER_MAINTENANCE_HEARTBEAT (1000) #define FPM_IDLE_SERVER_MAINTENANCE_HEARTBEAT (1000)
/* 130ms heartbeat for pctl */ /* a minimum of 130ms heartbeat for pctl */
#define FPM_PCTL_HEARTBEAT (130) #define FPM_PCTL_MIN_HEARTBEAT (130)
struct fpm_child_s; struct fpm_child_s;