Пример #1
0
static void subscription_destroy (flux_t h, subscription_t *sub)
{
    if (sub->type == FLUX_MSGTYPE_EVENT) {
        (void)flux_event_unsubscribe (h, sub->topic);
        flux_log (h, LOG_DEBUG, "event unsubscribe %s", sub->topic);
    }
    free (sub->topic);
    free (sub);
}
Пример #2
0
void shutdown_destroy (shutdown_t *s)
{
    if (s) {
        if (s->shutdown)
            flux_msg_handler_destroy (s->shutdown);
        if (s->h)
            (void)flux_event_unsubscribe (s->h, "shutdown");
        free (s);
    }
}
Пример #3
0
static void cron_event_destroy (void *arg)
{
    struct cron_event *ev = arg;
    if (ev == NULL)
        return;

    if (ev->mh)
        flux_msg_handler_destroy (ev->mh);
    if (ev->h && ev->event)
        (void) flux_event_unsubscribe (ev->h, ev->event);
    free (ev->event);
    free (ev);
}
Пример #4
0
// Received an event that a simulation is starting
static void start_cb (flux_t *h,
                      flux_msg_handler_t *w,
                      const flux_msg_t *msg,
                      void *arg)
{
    flux_log (h, LOG_DEBUG, "received a start event");
    if (send_join_request (h, module_name, -1) < 0) {
        flux_log (h, LOG_ERR, "failed to register with sim module");
        return;
    }
    flux_log (h, LOG_DEBUG, "sent a join request");

    if (flux_event_unsubscribe (h, "sim.start") < 0) {
        flux_log (h, LOG_ERR, "failed to unsubscribe from \"sim.start\"");
    } else {
        flux_log (h, LOG_DEBUG, "unsubscribed from \"sim.start\"");
    }
}
Пример #5
0
int main (int argc, char **argv)
{
    flux_t *h;
    flux_msg_t *msg;
    const char *topic;

    if (!(h = flux_open (NULL, 0)))
        log_err_exit ("flux_open");
    if (flux_event_subscribe (h, "hb") < 0)
        log_err_exit ("flux_event_subscribe");
    if (!(msg = flux_recv (h, FLUX_MATCH_EVENT, 0)))
        log_err_exit ("flux_recv");
    if (flux_msg_get_topic (msg, &topic) < 0)
        log_err_exit ("flux_msg_get_topic");
    printf ("Event: %s\n", topic);
    if (flux_event_unsubscribe (h, "hb") < 0)
        log_err_exit ("flux_event_unsubscribe");
    flux_msg_destroy (msg);
    flux_close (h);
    return (0);
}