示例#1
0
void check_codec (void)
{
    flux_msg_t *msg;
    int epoch;

    ok ((msg = flux_heartbeat_encode (44000)) != NULL,
        "flux_heartbeat_encode works");
    ok (flux_heartbeat_decode (msg, &epoch) == 0 && epoch == 44000,
        "flux_heartbeat_decode works and returns encoded epoch");
    flux_msg_destroy (msg);
}
示例#2
0
static void event_cb (flux_t *h, flux_msg_handler_t *mh,
                      const flux_msg_t *msg, void *arg)
{
    heartbeat_t *hb = arg;
    int epoch;

    if (flux_heartbeat_decode (msg, &epoch) < 0)
        return;
    if (epoch >= hb->epoch) { /* ensure epoch remains monotonic */
        hb->epoch = epoch;
    }
}
示例#3
0
void heartbeat_event_cb (flux_t h, flux_msg_watcher_t *w,
                          const flux_msg_t *msg, void *arg)
{
    heartbeat_t *hb = arg;
    int epoch = -1;
    int rc = flux_heartbeat_decode (msg, &epoch);

    ok (rc == 0 && heartbeat_recvmsg (hb, msg) == 0,
        "flux_heartbeat_recvmsg works, epoch %d", epoch);
    if (epoch == 2) {
        flux_msg_watcher_stop (h, w);
        heartbeat_stop (hb);
    }
}
示例#4
0
void heartbeat_event_cb (flux_t h, flux_msg_handler_t *w,
                          const flux_msg_t *msg, void *arg)
{
    heartbeat_t *hb = arg;
    int epoch = -1;
    int rc = flux_heartbeat_decode (msg, &epoch);

    ok (rc == 0,
        "received heartbeat event epoch %d", epoch);
    if (epoch == 2) {
        flux_msg_handler_stop (w);
        heartbeat_stop (hb);
    }
}