| 684 | } |
| 685 | |
| 686 | int 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 | |
| 724 | error: |
| 725 | lock_stop_read(cl_list_lock); |
| 726 | return -1; |
| 727 | } |
no test coverage detected