33#define fpm_event_set_timeout(ev, now) timeradd(&(now), &(ev)->frequency, &(ev)->timeout);
35static void fpm_event_cleanup(
int which,
void *
arg);
36static void fpm_postponed_children_bury(
struct fpm_event_s *ev,
short which,
void *
arg);
37static void fpm_got_signal(
struct fpm_event_s *ev,
short which,
void *
arg);
48static void fpm_event_cleanup(
int which,
void *
arg)
50 fpm_event_queue_destroy(&fpm_event_queue_timer);
51 fpm_event_queue_destroy(&fpm_event_queue_fd);
69 res = read(
fd, &c, 1);
70 }
while (
res == -1 &&
errno == EINTR);
120 }
else if (
ret == -1) {
151 if (queue->
ev == ev) {
169 if (fpm_event_queue_isset(*queue,
ev)) {
182 (*queue)->prev = elt;
188 if (*queue == fpm_event_queue_fd && module->add) {
214 (*queue)->prev =
NULL;
219 if (*queue == fpm_event_queue_fd && module->remove) {
240 if (*queue == fpm_event_queue_fd && module->clean) {
258 module = fpm_event_kqueue_module();
260 if (!mechanism ||
strcasecmp(module->name, mechanism) == 0) {
266 module = fpm_event_port_module();
268 if (!mechanism ||
strcasecmp(module->name, mechanism) == 0) {
274 module = fpm_event_epoll_module();
276 if (!mechanism ||
strcasecmp(module->name, mechanism) == 0) {
282 module = fpm_event_poll_module();
284 if (!mechanism ||
strcasecmp(module->name, mechanism) == 0) {
290 module = fpm_event_select_module();
292 if (!mechanism ||
strcasecmp(module->name, mechanism) == 0) {
298 zlog(
ZLOG_ERROR,
"event mechanism '%s' is not available on this system", mechanism);
300 zlog(
ZLOG_ERROR,
"unable to find a suitable event mechanism on this system");
308 return module ? module->name : NULL;
313 return module ? module->support_edge_trigger : 0;
327 zlog(
ZLOG_ERROR,
"Incomplete event implementation. Please open a bug report on https://github.com/php/php-src/issues.");
334 if (!wp->
config)
continue;
340 if (module->init(
max) < 0) {
341 zlog(
ZLOG_ERROR,
"Unable to initialize the event module %s", module->name);
345 zlog(
ZLOG_DEBUG,
"event module is %s and %d fds have been reserved", module->name,
max);
386 unsigned long int timeout;
398 q = fpm_event_queue_timer;
415 timeout = (tmp.tv_sec * 1000) + (tmp.tv_usec / 1000) + 1;
418 ret =
module->wait(fpm_event_queue_fd, timeout);
430 q = fpm_event_queue_timer;
449 if (q == fpm_event_queue_timer) {
450 fpm_event_queue_timer = q->
next;
451 if (fpm_event_queue_timer) {
452 fpm_event_queue_timer->prev =
NULL;
510 if (fpm_event_queue_add(&fpm_event_queue_fd, ev) != 0) {
520 if (frequency >= 1000) {
521 tmp.tv_sec = frequency / 1000;
522 tmp.tv_usec = (frequency % 1000) * 1000;
525 tmp.tv_usec = frequency * 1000;
530 if (fpm_event_queue_add(&fpm_event_queue_timer, ev) != 0) {
540 if (ev->
index >= 0 && fpm_event_queue_del(&fpm_event_queue_fd, ev) != 0) {
544 if (ev->
index < 0 && fpm_event_queue_del(&fpm_event_queue_timer, ev) != 0) {
memset(ptr, 0, type->size)
struct fpm_globals_s fpm_globals
void fpm_children_bury(void)
int fpm_cleanup_add(int type, void(*cleanup)(int, void *), void *arg)
int fpm_clock_get(struct timeval *tv)
#define timercmp(a, b, CMP)
#define timersub(tvp, uvp, vvp)
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_pre_init(char *mechanism)
int fpm_event_add(struct fpm_event_s *ev, unsigned long int frequency)
int fpm_event_init_main(void)
int fpm_event_support_edge_trigger(void)
void fpm_event_fire(struct fpm_event_s *ev)
#define fpm_event_set_timeout(ev, now)
const char * fpm_event_mechanism_name(void)
void fpm_event_loop(int err)
int fpm_event_del(struct fpm_event_s *ev)
#define fpm_event_set_timer(ev, flags, cb, arg)
int fpm_log_open(int reopen)
void fpm_pctl(int new_state, int action)
void fpm_pctl_heartbeat(struct fpm_event_s *ev, short which, void *arg)
void fpm_pctl_perform_idle_server_maintenance_heartbeat(struct fpm_event_s *ev, short which, void *arg)
@ FPM_PCTL_STATE_TERMINATING
@ FPM_PCTL_STATE_FINISHING
@ FPM_PCTL_STATE_RELOADING
size_t fpm_shm_get_size_allocated(void)
int fpm_signals_get_fd(void)
int fpm_stdio_redirect_stderr_to_error_log(void)
int fpm_stdio_open_error_log(int reopen)
int fpm_stdio_restore_original_stderr(int close_after_restore)
void fpm_systemd_heartbeat(struct fpm_event_s *ev, short which, void *arg)
struct fpm_worker_pool_s * fpm_worker_all_pools
struct fpm_event_queue_s * prev
struct fpm_event_queue_s * next
void(* callback)(struct fpm_event_s *, short, void *)
struct fpm_worker_pool_config_s * config
struct fpm_worker_pool_s * next
#define strcasecmp(s1, s2)