]> granicus.if.org Git - php/commitdiff
- Fixed bug #55526 (Heartbeat causes a lot of unnecessary events)
authorJérôme Loyet <fat@php.net>
Sun, 9 Oct 2011 15:12:26 +0000 (15:12 +0000)
committerJérôme Loyet <fat@php.net>
Sun, 9 Oct 2011 15:12:26 +0000 (15:12 +0000)
sapi/fpm/fpm/fpm.c
sapi/fpm/fpm/fpm.h
sapi/fpm/fpm/fpm_conf.c
sapi/fpm/fpm/fpm_events.c
sapi/fpm/fpm/fpm_process_ctl.c
sapi/fpm/fpm/fpm_process_ctl.h

index d405949ae4bee04e4fd164567639f588ed37d180..96aabbfc49959e3a8fb2cd4811d3332f424b8ac4 100644 (file)
@@ -36,7 +36,8 @@ struct fpm_globals_s fpm_globals = {
        .listening_socket = 0,
        .max_requests = 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) /* {{{ */
index 3c6f798fba6ff127f2b1b918c3d5a10b9c4b8e79..bfeac4d67d8d4a549dc8b7d235b8e6bd963e4025 100644 (file)
@@ -24,6 +24,7 @@ struct fpm_globals_s {
        int max_requests; /* for this child */
        int is_child;
        int test_successful;
+       int heartbeat;
 };
 
 extern struct fpm_globals_s fpm_globals;
index 82a45e5da690118afda18b6aa2267cb2c1bacccc..3c7a73a8bffde7252fb5d6452ab81c83bc2c2227 100644 (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 */
                if (wp->config->slowlog && *wp->config->slowlog) {
                        fpm_evaluate_full_path(&wp->config->slowlog, wp, NULL, 0);
@@ -912,6 +916,8 @@ static int fpm_conf_process_all_pools() /* {{{ */
                                }
                                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 */
index ab3a69df860ad60084c5c8d955c5ae8569c25c8c..d5f7483b4f17f9c495c7f09b8862f331e2bfa366 100644 (file)
@@ -350,7 +350,9 @@ void fpm_event_loop(int err) /* {{{ */
        fpm_event_add(&signal_fd_event, 0);
 
        /* add timers */
-       fpm_pctl_heartbeat(NULL, 0, NULL);
+       if (fpm_globals.heartbeat > 0) {
+               fpm_pctl_heartbeat(NULL, 0, NULL);
+       }
 
        if (!err) {
                fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL);
index 5d80aedbdbe3d653f0d6fb50a1b96f8d5c6d86c7..685443427ebe76a1808c340566a1bb8988ad5702 100644 (file)
@@ -453,9 +453,13 @@ void fpm_pctl_heartbeat(struct fpm_event_s *ev, short which, void *arg) /* {{{ *
                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 */
+       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_add(&heartbeat, FPM_PCTL_HEARTBEAT);
+       fpm_event_add(&heartbeat, fpm_globals.heartbeat);
 }
 /* }}} */
 
index ad755e612a325f3209fcd47b3670990dce87769f..86a6ef0dfbb4b6fc6bf5b8ed5bb22da76be63d62 100644 (file)
@@ -11,8 +11,9 @@
 #define FPM_MAX_SPAWN_RATE (32)
 /* 1s (in ms) heartbeat for idle server maintenance */
 #define FPM_IDLE_SERVER_MAINTENANCE_HEARTBEAT (1000)
-/* 130ms heartbeat for pctl */
-#define FPM_PCTL_HEARTBEAT (130)
+/* a minimum of 130ms heartbeat for pctl */
+#define FPM_PCTL_MIN_HEARTBEAT (130)
+
 
 struct fpm_child_s;