/** * Update info on a node. * * This may have the side-effect of changing our state to CHANGED. * * \param node Node to update the info on * \param[in] ping Ping received from #node */ static void update_node_info(sup_node_t *node, const sup_ping_t *ping) { bool inca_changed, view_changed; bool rebooted_too_fast; inca_changed = (ping->incarnation != node->incarnation); view_changed = !sup_view_equals(&ping->view, &node->view); /* If the node's incarnation has changed but the node was not seen down * in-between, it means the node has rebooted faster than ping_timeout */ rebooted_too_fast = self_sees(node) && inca_changed; node->incarnation = ping->incarnation; sup_view_copy(&node->view, &ping->view); if (rebooted_too_fast) { __trace("node %u rebooted too fast, marking it dead", node->id); mark_dead(node); } else mark_alive(node); if (inca_changed || view_changed) { __trace("node %u's view changed", node->id); other_view_changed = true; } }
/** * Send a ping to all instances of Csupd using examsg. * * \param[in] cluster Cluster * \param[in] view View to send */ void sup_send_ping(const sup_cluster_t *cluster, const sup_view_t *view) { sup_ping_msg_t ping_msg; int err; ping_msg.any.type = EXAMSG_SUP_PING; ping_msg.ping.sender = cluster->self->id; ping_msg.ping.incarnation = cluster->self->incarnation; sup_view_copy(&ping_msg.ping.view, view); EXA_ASSERT(sup_check_ping(&ping_msg.ping, 'S')); err = examsgSendNoBlock(sup_mh, EXAMSG_CMSGD_ID, EXAMSG_LOCALHOST, &ping_msg, sizeof(ping_msg)); if (err != sizeof(ping_msg)) __debug("cannot send ping : %s (%d)", exa_error_msg(err), err); }