| 1675 | } |
| 1676 | |
| 1677 | int send_cap_update(node_info_t *dest_node, int require_reply) |
| 1678 | { |
| 1679 | bin_packet_t packet; |
| 1680 | str bin_buffer; |
| 1681 | struct local_cap *cl_cap; |
| 1682 | struct remote_cap *n_cap; |
| 1683 | int nr_cap, nr_nodes = 0; |
| 1684 | node_info_t *node; |
| 1685 | int timestamp; |
| 1686 | |
| 1687 | timestamp = (int)(unsigned long)time(NULL); |
| 1688 | |
| 1689 | if (dest_node->cluster->capabilities) |
| 1690 | nr_nodes++; |
| 1691 | |
| 1692 | for (node = dest_node->cluster->node_list; node; node = node->next) { |
| 1693 | lock_get(node->lock); |
| 1694 | if (node->capabilities && node->node_id != dest_node->node_id) |
| 1695 | nr_nodes++; |
| 1696 | lock_release(node->lock); |
| 1697 | } |
| 1698 | |
| 1699 | if (nr_nodes == 0) |
| 1700 | return 0; |
| 1701 | |
| 1702 | if (bin_init(&packet, &cl_internal_cap, CLUSTERER_CAP_UPDATE, BIN_VERSION, 0) < 0) { |
| 1703 | LM_ERR("Failed to init bin send buffer\n"); |
| 1704 | return -1; |
| 1705 | } |
| 1706 | bin_push_int(&packet, dest_node->cluster->cluster_id); |
| 1707 | bin_push_int(&packet, current_id); |
| 1708 | |
| 1709 | lock_get(dest_node->cluster->current_node->lock); |
| 1710 | |
| 1711 | bin_push_int(&packet, ++dest_node->cluster->current_node->cap_seq_no); |
| 1712 | bin_push_int(&packet, timestamp); |
| 1713 | |
| 1714 | lock_release(dest_node->cluster->current_node->lock); |
| 1715 | |
| 1716 | bin_push_int(&packet, nr_nodes); |
| 1717 | |
| 1718 | /* current node's capabilities */ |
| 1719 | for (cl_cap = dest_node->cluster->capabilities, nr_cap = 0; cl_cap; |
| 1720 | cl_cap = cl_cap->next, nr_cap++) ; |
| 1721 | if (nr_cap) { |
| 1722 | bin_push_int(&packet, current_id); |
| 1723 | bin_push_int(&packet, nr_cap); |
| 1724 | for (cl_cap=dest_node->cluster->capabilities;cl_cap;cl_cap=cl_cap->next) { |
| 1725 | bin_push_str(&packet, &cl_cap->reg.name); |
| 1726 | lock_get(dest_node->cluster->lock); |
| 1727 | bin_push_int(&packet, cl_cap->flags & CAP_STATE_OK ? 1 : 0); |
| 1728 | lock_release(dest_node->cluster->lock); |
| 1729 | } |
| 1730 | } |
| 1731 | |
| 1732 | /* known capabilities for other nodes */ |
| 1733 | for (node = dest_node->cluster->node_list; node; node = node->next) { |
| 1734 | if (node->node_id == dest_node->node_id) |
no test coverage detected