/** Initiate connection if we are disconnected */ static int __connect_if_needed(peer_connection_t* conn) { if (CONNECTED != conn->connection_status) { if (DISCONNECTED == conn->connection_status) __connect_to_peer(conn); return -1; } return 0; }
void algopr_update_client_connections(const exa_nodeset_t *mship) { exa_nodeid_t node_id; os_thread_mutex_lock(&peers_lock); for (node_id = 0; node_id < EXA_MAX_NODES_NUMBER; node_id++) { /* FIXME Handle errors */ if (exa_nodeset_contains(mship, node_id) && !__peer_is_connected(node_id)) { /* Don't connect to self nor to nodes with a higher node id */ if (node_id < this_node_id) __connect_to_peer(node_id); } else if (!exa_nodeset_contains(mship, node_id) && __peer_is_connected(node_id)) __disconnect_from_peer(node_id); } os_thread_mutex_unlock(&peers_lock); }