Skip to content

Commit

Permalink
clusterer: issue sync request under lock
Browse files Browse the repository at this point in the history
(cherry picked from commit bf178b0)
  • Loading branch information
rvlad-patrascu committed Jul 20, 2022
1 parent 652d89f commit 383b232
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/clusterer/api.h
Expand Up @@ -179,6 +179,7 @@ typedef int (*register_capability_f)(str *cap, cl_packet_cb_f packet_cb,
* Request to synchronize data for a given capability from another node.
*/
typedef int (*request_sync_f)(str * capability, int cluster_id);

/*
* Returns a BIN packet in which to include a distinct "chunk" of data
* (e.g. info about a single usrloc contact) to sync.
Expand Down
4 changes: 4 additions & 0 deletions modules/clusterer/sync.c
Expand Up @@ -96,6 +96,8 @@ int cl_request_sync(str *capability, int cluster_id)
LM_DBG("requesting %.*s sync in cluster %d\n",
capability->len, capability->s, cluster_id);

lock_start_read(cl_list_lock);

cluster = get_cluster_by_id(cluster_id);
if (!cluster) {
LM_ERR("Unknown cluster [%d]\n", cluster_id);
Expand Down Expand Up @@ -151,6 +153,8 @@ int cl_request_sync(str *capability, int cluster_id)
}
}

lock_stop_read(cl_list_lock);

return 0;
}

Expand Down

0 comments on commit 383b232

Please sign in to comment.