.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) /* {{{ */
int max_requests; /* for this child */
int is_child;
int test_successful;
+ int heartbeat;
};
extern struct fpm_globals_s fpm_globals;
}
}
+ 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);
}
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 */
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);
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);
}
/* }}} */
#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;