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

Function update_sync_chunks_cnt

modules/clusterer/sync.c:686–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684}
685
686int update_sync_chunks_cnt(int cluster_id, str *cap_name, int source_id)
687{
688 cluster_info_t *cluster;
689 struct local_cap *cap;
690
691 lock_start_read(cl_list_lock);
692
693 cluster = get_cluster_by_id(cluster_id);
694 if (!cluster) {
695 LM_ERR("unknown cluster, id [%d]\n", cluster_id);
696 goto error;
697 }
698
699 for (cap = cluster->capabilities; cap; cap = cap->next)
700 if (!str_strcmp(&cap->reg.name, cap_name))
701 break;
702 if (!cap) {
703 LM_ERR("capability: %.*s not found in cluster info\n",
704 cap_name->len, cap_name->s);
705 goto error;
706 }
707
708 lock_get(cluster->lock);
709
710 cap->sync_cur_chunks_cnt += no_sync_chunks_iter;
711
712 /* if we know the total number of chunks and this is the last chunk,
713 * run the sync end actions */
714 if (cap->sync_total_chunks_cnt != 0 &&
715 cap->sync_cur_chunks_cnt == cap->sync_total_chunks_cnt)
716 handle_sync_end(cluster, cap, source_id, cap->sync_total_chunks_cnt, 0);
717
718 lock_release(cluster->lock);
719
720 lock_stop_read(cl_list_lock);
721
722 return 0;
723
724error:
725 lock_stop_read(cl_list_lock);
726 return -1;
727}

Callers 1

run_mod_packet_cbFunction · 0.85

Calls 4

get_cluster_by_idFunction · 0.85
lock_getFunction · 0.85
handle_sync_endFunction · 0.85
lock_releaseFunction · 0.85

Tested by

no test coverage detected