/** * Process a ping message * * \param[in] ping Ping to process */ static void sup_process_ping(const sup_ping_t *ping) { sup_node_t *node; #ifdef WITH_TRACE __trace("<-- from node %u: incarnation=%hu", ping->sender, ping->incarnation); sup_view_debug(&ping->view); #endif EXA_ASSERT(sup_check_ping(ping, 'R')); node = sup_cluster_node(&cluster, ping->sender); if (node == NULL) { /* First time the node is seen, let's add it to the cluster */ sup_cluster_add_node(&cluster, ping->sender); node = sup_cluster_node(&cluster, ping->sender); EXA_ASSERT(node); } if (node != self) update_node_info(node, ping); switch (self->view.state) { case SUP_STATE_UNKNOWN: /* Can't possibly be in UNKNOWN state */ EXA_ASSERT(false); break; case SUP_STATE_CHANGE: state_change_process_ping(ping); break; case SUP_STATE_ACCEPT: state_accept_process_ping(ping); break; case SUP_STATE_COMMIT: state_commit_process_ping(ping); break; } }
/** * 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); }