MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / handle_cap_update

Function handle_cap_update

modules/clusterer/clusterer.c:917–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915}
916
917static void handle_cap_update(bin_packet_t *packet, node_info_t *source)
918{
919 str cap;
920 int nr_cap, i, j;
921 struct remote_cap *cur;
922 struct local_cap *lcap;
923 int nr_nodes;
924 int node_id;
925 node_info_t *node;
926 int cap_state;
927 int rc;
928 int require_reply;
929 int seq_no, timestamp;
930
931 bin_pop_int(packet, &seq_no);
932 bin_pop_int(packet, &timestamp);
933
934 lock_get(source->lock);
935 if (validate_update(source->cap_seq_no, seq_no,
936 source->cap_timestamp, timestamp, 0, source->node_id) < 0) {
937 lock_release(source->lock);
938 return;
939 } else {
940 source->cap_seq_no = seq_no;
941 source->cap_timestamp = timestamp;
942 }
943 lock_release(source->lock);
944
945 bin_pop_int(packet, &nr_nodes);
946
947 for (i = 0; i < nr_nodes; i++) {
948 bin_pop_int(packet, &node_id);
949
950 if (node_id == current_id) {
951 bin_pop_int(packet, &nr_cap);
952 for (j = 0; j < nr_cap; j++) {
953 bin_pop_str(packet, &cap);
954 bin_pop_int(packet, &cap_state);
955 }
956 continue;
957 }
958 node = get_node_by_id(source->cluster, node_id);
959 if (!node) {
960 LM_ERR("Unknown id [%d] in capability update from node [%d]\n",
961 node_id, source->node_id);
962 return;
963 }
964
965 bin_pop_int(packet, &nr_cap);
966 for (j = 0; j < nr_cap; j++) {
967 bin_pop_str(packet, &cap);
968 bin_pop_int(packet, &cap_state);
969
970 lock_get(node->lock);
971
972 for (cur = node->capabilities; cur && str_strcmp(&cap, &cur->name);
973 cur = cur->next) ;
974 if (!cur) { /* new capability */

Callers 1

handle_internal_msgFunction · 0.85

Calls 11

bin_pop_intFunction · 0.85
lock_getFunction · 0.85
validate_updateFunction · 0.85
lock_releaseFunction · 0.85
bin_pop_strFunction · 0.85
get_node_by_idFunction · 0.85
shm_mallocFunction · 0.85
match_nodeFunction · 0.85
send_sync_reqFunction · 0.85
send_cap_updateFunction · 0.85
flood_messageFunction · 0.85

Tested by

no test coverage detected