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

Function get_sync_source

modules/clusterer/sync.c:63–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63static int get_sync_source(cluster_info_t *cluster, str *capability,
64 enum cl_node_match_op match_cond)
65{
66 node_info_t *node;
67 struct remote_cap *cap;
68
69 for (node = cluster->node_list; node; node = node->next) {
70 if (get_next_hop(node) == 0)
71 continue;
72
73 if (!match_node(cluster->current_node, node, match_cond))
74 continue;
75
76 lock_get(node->lock);
77 for (cap = node->capabilities; cap; cap = cap->next)
78 if (!str_strcmp(capability, &cap->name))
79 break;
80
81 /* if the node does have the capability and it's in the OK state
82 * then it can be a source for syncing */
83 if (cap && cap->flags & CAP_STATE_OK) {
84 lock_release(node->lock);
85 return node->node_id;
86 }
87
88 lock_release(node->lock);
89 }
90
91 return 0;
92}
93
94int queue_sync_request(cluster_info_t *cluster, struct local_cap *lcap)
95{

Callers 1

cl_request_syncFunction · 0.85

Calls 4

get_next_hopFunction · 0.85
match_nodeFunction · 0.85
lock_getFunction · 0.85
lock_releaseFunction · 0.85

Tested by

no test coverage detected