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

Function handle_sync_request

modules/clusterer/sync.c:435–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435void handle_sync_request(bin_packet_t *packet, cluster_info_t *cluster,
436 node_info_t *source)
437{
438 str cap_name;
439 struct remote_cap *cap;
440 int rc;
441
442 bin_pop_str(packet, &cap_name);
443
444 LM_INFO("Received sync request for capability '%.*s' from node %d, "
445 "cluster %d\n", cap_name.len, cap_name.s, source->node_id,
446 cluster->cluster_id);
447
448 rc = get_capability_status(cluster, &cap_name);
449 if (rc == -1) {
450 return;
451 } else if (rc == 0) {
452 LM_DBG("capability disabled, drop sync request\n");
453 return;
454 }
455
456 if (get_next_hop(source)) {
457 if (ipc_dispatch_sync_reply(cluster, source->node_id, &cap_name) < 0)
458 LM_ERR("Failed to dispatch sync reply job\n");
459 } else {
460 lock_get(source->lock);
461
462 for (cap = source->capabilities; cap; cap = cap->next)
463 if (!str_strcmp(&cap_name, &cap->name))
464 break;
465 if (!cap) {
466 LM_ERR("Requesting node does not appear to have capability: %.*s\n",
467 cap_name.len, cap_name.s);
468 lock_release(source->lock);
469 return;
470 }
471
472 /* reply to sync later when the node is up */
473 cap->flags |= CAP_SYNC_PENDING;
474 lock_release(source->lock);
475 }
476}
477
478static void run_cb_buf_pkt(int sender, void *param)
479{

Callers 1

bin_rcv_cl_extra_packetsFunction · 0.85

Calls 6

bin_pop_strFunction · 0.85
get_capability_statusFunction · 0.85
get_next_hopFunction · 0.85
ipc_dispatch_sync_replyFunction · 0.85
lock_getFunction · 0.85
lock_releaseFunction · 0.85

Tested by

no test coverage detected