summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Loyet <fat@php.net>2011-10-09 15:12:26 +0000
committerJérôme Loyet <fat@php.net>2011-10-09 15:12:26 +0000
commit891ca5cae3de82cad8d909bb8b83b9717f0aa111 (patch)
treebfc61589db8e2a209c8e20fcdd22e213315f3d10
parent17cbee6ffe55eb5dd46e009526d9c401dded6cce (diff)
downloadphp-git-891ca5cae3de82cad8d909bb8b83b9717f0aa111.tar.gz
- Fixed bug #55526 (Heartbeat causes a lot of unnecessary events)
-rw-r--r--sapi/fpm/fpm/fpm.c3
-rw-r--r--sapi/fpm/fpm/fpm.h1
-rw-r--r--sapi/fpm/fpm/fpm_conf.c6
-rw-r--r--sapi/fpm/fpm/fpm_events.c4
-rw-r--r--sapi/fpm/fpm/fpm_process_ctl.c6
-rw-r--r--sapi/fpm/fpm/fpm_process_ctl.h5
6 files changed, 20 insertions, 5 deletions
diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c
index d405949ae4..96aabbfc49 100644
--- a/sapi/fpm/fpm/fpm.c
+++ b/sapi/fpm/fpm/fpm.c
@@ -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) /* {{{ */
diff --git a/sapi/fpm/fpm/fpm.h b/sapi/fpm/fpm/fpm.h
index 3c6f798fba..bfeac4d67d 100644
--- a/sapi/fpm/fpm/fpm.h
+++ b/sapi/fpm/fpm/fpm.h
@@ -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;
diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c
index 82a45e5da6..3c7a73a8bf 100644
--- a/sapi/fpm/fpm/fpm_conf.c
+++ b/sapi/fpm/fpm/fpm_conf.c
@@ -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 */
diff --git a/sapi/fpm/fpm/fpm_events.c b/sapi/fpm/fpm/fpm_events.c
index ab3a69df86..d5f7483b4f 100644
--- a/sapi/fpm/fpm/fpm_events.c
+++ b/sapi/fpm/fpm/fpm_events.c
@@ -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);
diff --git a/sapi/fpm/fpm/fpm_process_ctl.c b/sapi/fpm/fpm/fpm_process_ctl.c
index 5d80aedbdb..685443427e 100644
--- a/sapi/fpm/fpm/fpm_process_ctl.c
+++ b/sapi/fpm/fpm/fpm_process_ctl.c
@@ -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);
}
/* }}} */
diff --git a/sapi/fpm/fpm/fpm_process_ctl.h b/sapi/fpm/fpm/fpm_process_ctl.h
index ad755e612a..86a6ef0dfb 100644
--- a/sapi/fpm/fpm/fpm_process_ctl.h
+++ b/sapi/fpm/fpm/fpm_process_ctl.h
@@ -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;