32static time_t *last_faults;
35static void fpm_children_cleanup(
int which,
void *
arg)
52 ret->scoreboard_i = -1;
56static void fpm_child_free(
struct fpm_child_s *child)
66static void fpm_postponed_child_free(
struct fpm_event_s *ev,
short which,
void *
arg)
82static void fpm_child_close(
struct fpm_child_s *child,
int in_event_loop)
108 fpm_child_free(child);
113static void fpm_child_link(
struct fpm_child_s *child)
129static void fpm_child_unlink(
struct fpm_child_s *child)
170static int fpm_child_cloexec(
void)
173 int attrs = fcntl(
fpm_globals.listening_socket, F_GETFD);
200 0 > fpm_child_cloexec()) {
212 for (; child; child =
next) {
214 fpm_child_close(child, 0 );
230 int restart_child = 1;
249 }
else if (WIFSIGNALED(
status)) {
252 const char *have_core = WCOREDUMP(
status) ?
" - core dumped" :
"";
254 const char* have_core =
"";
257 if (signame ==
NULL) {
273 }
else if (WIFSTOPPED(
status)) {
277 if (child && child->
tracer) {
286 struct timeval tv1, tv2;
288 fpm_child_unlink(child);
300 zlog(severity,
"[pool %s] child %d exited %s after %ld.%06d seconds from start", wp->
config->
name, (
int) pid,
buf, (
long)tv2.tv_sec, (
int) tv2.tv_usec);
302 zlog(
ZLOG_DEBUG,
"[pool %s] child %d has been killed by the process management after %ld.%06d seconds from start", wp->
config->
name, (
int) pid, (
long)tv2.tv_sec, (
int) tv2.tv_usec);
305 fpm_child_close(child, 1 );
310 time_t
now = tv1.tv_sec;
311 int restart_condition = 1;
314 last_faults[fault++] =
now;
322 restart_condition = 0;
327 if (restart_condition) {
343 zlog(
ZLOG_DEBUG,
"unknown child (%d) exited %s - most likely an orphan process (master process is the init process)", pid,
buf);
345 zlog(
ZLOG_WARNING,
"unknown child (%d) exited %s - potentially a bug or pre exec child (e.g. s6-notifyoncheck)", pid,
buf);
354 c = fpm_child_alloc();
379static void fpm_resources_discard(
struct fpm_child_s *child)
383 fpm_child_free(child);
387static void fpm_child_resources_use(
struct fpm_child_s *child)
391 if (wp == child->
wp || wp == child->
wp->
shared) {
399 fpm_child_free(child);
403static void fpm_parent_resources_use(
struct fpm_child_s *child)
406 fpm_child_link(child);
415 static int warned = 0;
418 if (!in_event_loop) {
424 if (!in_event_loop) {
443 child = fpm_resources_prepare(
wp);
459 fpm_child_resources_use(child);
469 fpm_resources_discard(child);
477 fpm_parent_resources_use(child);
487 zlog(
ZLOG_WARNING,
"The maximum number of processes has been reached. Please review your configuration and consider raising 'process.max'");
522 last_faults = malloc(
sizeof(time_t) *
fpm_global_config.emergency_restart_threshold);
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
struct fpm_globals_s fpm_globals
#define FPM_EXIT_SOFTWARE
struct fpm_child_s * fpm_child_find(pid_t pid)
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug)
int fpm_children_create_initial(struct fpm_worker_pool_s *wp)
int fpm_children_free(struct fpm_child_s *child)
void fpm_children_bury(void)
int fpm_children_init_main(void)
int fpm_cleanup_add(int type, void(*cleanup)(int, void *), void *arg)
int fpm_clock_get(struct timeval *tv)
struct fpm_global_config_s fpm_global_config
#define timersub(tvp, uvp, vvp)
int fpm_env_init_child(struct fpm_worker_pool_s *wp)
int fpm_event_set(struct fpm_event_s *ev, int fd, int flags, void(*callback)(struct fpm_event_s *, short, void *), void *arg)
int fpm_event_add(struct fpm_event_s *ev, unsigned long int frequency)
void fpm_event_fire(struct fpm_event_s *ev)
int fpm_event_del(struct fpm_event_s *ev)
#define fpm_event_set_timer(ev, flags, cb, arg)
int fpm_log_init_child(struct fpm_worker_pool_s *wp)
int fpm_php_init_child(struct fpm_worker_pool_s *wp)
void fpm_pctl(int new_state, int action)
int fpm_pctl_can_spawn_children(void)
void fpm_pctl_on_socket_accept(struct fpm_event_s *ev, short which, void *arg)
int fpm_pctl_child_exited(void)
@ FPM_PCTL_STATE_RELOADING
void fpm_scoreboard_free(struct fpm_worker_pool_s *wp)
void fpm_scoreboard_child_use(struct fpm_child_s *child, pid_t pid)
void fpm_scoreboard_proc_free(struct fpm_child_s *child)
int fpm_scoreboard_proc_alloc(struct fpm_child_s *child)
int fpm_signals_unblock(void)
int fpm_signals_init_child(void)
const char * fpm_signal_names[NSIG+1]
int fpm_signals_child_block(void)
int fpm_status_init_child(struct fpm_worker_pool_s *wp)
int fpm_stdio_init_child(struct fpm_worker_pool_s *wp)
int fpm_stdio_discard_pipes(struct fpm_child_s *child)
void fpm_stdio_child_use_pipes(struct fpm_child_s *child)
int fpm_stdio_prepare_pipes(struct fpm_child_s *child)
int fpm_stdio_parent_use_pipes(struct fpm_child_s *child)
int fpm_unix_init_child(struct fpm_worker_pool_s *wp)
struct fpm_worker_pool_s * fpm_worker_all_pools
void(* tracer)(struct fpm_child_s *)
struct fpm_event_s ev_stdout ev_stderr ev_free
struct fpm_child_s * prev
struct fpm_child_s * next
struct fpm_worker_pool_s * wp
struct zlog_stream * log_stream
struct fpm_worker_pool_config_s * config
struct fpm_event_s * ondemand_event
struct fpm_worker_pool_s * shared
struct fpm_worker_pool_s * next
struct fpm_child_s * children
exit(string|int $status=0)
zlog_bool zlog_stream_close(struct zlog_stream *stream)