| 1608 | } |
| 1609 | |
| 1610 | int send_single_cap_update(cluster_info_t *cluster, struct local_cap *cap, |
| 1611 | int cap_state) |
| 1612 | { |
| 1613 | bin_packet_t packet; |
| 1614 | str bin_buffer; |
| 1615 | node_info_t* destinations[MAX_NO_NODES]; |
| 1616 | struct neighbour *neigh; |
| 1617 | int no_dests = 0, i; |
| 1618 | int timestamp; |
| 1619 | |
| 1620 | timestamp = (int)(unsigned long)time(NULL); |
| 1621 | |
| 1622 | lock_get(cluster->current_node->lock); |
| 1623 | |
| 1624 | for (neigh = cluster->current_node->neighbour_list; neigh; |
| 1625 | neigh = neigh->next) |
| 1626 | destinations[no_dests++] = neigh->node; |
| 1627 | |
| 1628 | if (no_dests == 0) { |
| 1629 | lock_release(cluster->current_node->lock); |
| 1630 | return 0; |
| 1631 | } |
| 1632 | |
| 1633 | if (bin_init(&packet, &cl_internal_cap, CLUSTERER_CAP_UPDATE, |
| 1634 | BIN_VERSION, 0) < 0) { |
| 1635 | lock_release(cluster->current_node->lock); |
| 1636 | LM_ERR("Failed to init bin send buffer\n"); |
| 1637 | return -1; |
| 1638 | } |
| 1639 | bin_push_int(&packet, cluster->cluster_id); |
| 1640 | bin_push_int(&packet, current_id); |
| 1641 | |
| 1642 | bin_push_int(&packet, ++cluster->current_node->cap_seq_no); |
| 1643 | bin_push_int(&packet, timestamp); |
| 1644 | |
| 1645 | lock_release(cluster->current_node->lock); |
| 1646 | |
| 1647 | /* only the current node */ |
| 1648 | bin_push_int(&packet, 1); |
| 1649 | bin_push_int(&packet, current_id); |
| 1650 | |
| 1651 | /* only a single capability */ |
| 1652 | bin_push_int(&packet, 1); |
| 1653 | bin_push_str(&packet, &cap->reg.name); |
| 1654 | bin_push_int(&packet, cap_state); |
| 1655 | |
| 1656 | bin_push_int(&packet, 0); /* don't require reply */ |
| 1657 | |
| 1658 | bin_push_int(&packet, 1); /* path length is 1, only current node at this point */ |
| 1659 | bin_push_int(&packet, current_id); |
| 1660 | bin_get_buffer(&packet, &bin_buffer); |
| 1661 | |
| 1662 | for (i = 0; i < no_dests; i++) |
| 1663 | if (msg_send(cluster->send_sock, destinations[i]->proto, |
| 1664 | &destinations[i]->addr, 0, bin_buffer.s, bin_buffer.len, 0) < 0) { |
| 1665 | LM_ERR("Failed to send capability update to node [%d]\n", |
| 1666 | destinations[i]->node_id); |
| 1667 | set_link_w_neigh_adv(-1, LS_RESTART_PINGING, destinations[i]); |
no test coverage detected