F_NONNULL static void die_gracefully(struct ev_loop* loop) { dmn_assert(loop); dmn_assert(killed_by); static bool done_once = false; if(!done_once) { // avoid repetition done_once = true; // send friendly death message to plugin sendq_enq(emc_encode_exit()); ev_io_start(loop, plugin_write_watcher); // kill interval timers for future invocations // and immediately clamp the remaining timeout // for any running commands to 2.0s. for(unsigned i = 0; i < num_mons; i++) { ev_timer_stop(loop, mons[i].interval_timer); if(ev_is_active(mons[i].cmd_timeout)) { if(ev_timer_remaining(loop, mons[i].cmd_timeout) > 2.0) { ev_timer_stop(loop, mons[i].cmd_timeout); ev_timer_set(mons[i].cmd_timeout, 2.0, 0.); ev_timer_start(loop, mons[i].cmd_timeout); } } } } }
double flux_watcher_next_wakeup (flux_watcher_t *w) { if (w->signature == PERIODIC_SIG) { struct f_periodic *fp = w->impl; return ((double) ev_periodic_at (&fp->evp)); } else if (w->signature == TIMER_SIG) { ev_timer *tw = w->impl; struct ev_loop *loop = w->r->loop; return ((double) (ev_now (loop) + ev_timer_remaining (loop, tw))); } errno = EINVAL; return (-1.); }