int shutdown_recvmsg (shutdown_t *s, const flux_msg_t *msg) { int rc = -1; if (!s->w) { if (shutdown_decode (msg, &s->grace, &s->rc, &s->rank, s->reason, sizeof (s->reason)) < 0) goto done; if (!(s->w = flux_timer_watcher_create (s->grace, 0., shutdown_cb, s))) goto done; flux_timer_watcher_start (s->h, s->w); if (flux_rank (s->h) == 0) flux_log (s->h, LOG_INFO, "%d: shutdown in %.3fs: %s", s->rank, s->grace, s->reason); } rc = 0; done: return rc; }
/* On receipt of the shutdown event message, begin the grace timer, * and log the "shutdown in..." message on rank 0. */ void shutdown_handler (flux_t h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { shutdown_t *s = arg; if (!s->timer) { if (shutdown_decode (msg, &s->grace, &s->rc, &s->rank, s->reason, sizeof (s->reason)) < 0) { flux_log_error (h, "shutdown event"); return; } if (!(s->timer = flux_timer_watcher_create (flux_get_reactor (s->h), s->grace, 0., timer_handler, s))) { flux_log_error (h, "shutdown timer creation"); return; } flux_watcher_start (s->timer); if (s->myrank == 0) flux_log (s->h, LOG_INFO, "shutdown in %.3fs: %s", s->grace, s->reason); } }