Skip to content

Commit

Permalink
Fix MI cluster sync when node is seed
Browse files Browse the repository at this point in the history
(cherry picked from commit a029ba7)
  • Loading branch information
rvlad-patrascu committed Apr 29, 2018
1 parent 7b3089e commit 3474153
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/clusterer/api.h
Expand Up @@ -173,7 +173,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);
typedef int (*request_sync_f)(str * capability, int cluster_id, int ignore_seed);
/*
* 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: 2 additions & 2 deletions modules/clusterer/sync.c
Expand Up @@ -84,7 +84,7 @@ static int get_sync_source(cluster_info_t *cluster, str *capability,
return 0;
}

int cl_request_sync(str *capability, int cluster_id)
int cl_request_sync(str *capability, int cluster_id, int ignore_seed)
{
cluster_info_t *cluster;
struct local_cap *lcap;
Expand All @@ -110,7 +110,7 @@ int cl_request_sync(str *capability, int cluster_id)
}

/* the seed node is already considered synchronized */
if (cluster->current_node->flags & NODE_IS_SEED) {
if (!ignore_seed && (cluster->current_node->flags & NODE_IS_SEED)) {
LM_DBG("we are a seed node - sync is not required\n");
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/clusterer/sync.h
Expand Up @@ -27,7 +27,7 @@

extern int sync_packet_size;

int cl_request_sync(str *capability, int cluster_id);
int cl_request_sync(str *capability, int cluster_id, int ignore_seed);
bin_packet_t *cl_sync_chunk_start(str *capability, int cluster_id, int dst_id);
int cl_sync_chunk_iter(bin_packet_t *packet);

Expand Down
2 changes: 1 addition & 1 deletion modules/dialog/dialog.c
Expand Up @@ -873,7 +873,7 @@ static int mod_init(void)
return -1;
}

if (clusterer_api.request_sync(&dlg_repl_cap, dialog_repl_cluster) < 0)
if (clusterer_api.request_sync(&dlg_repl_cap, dialog_repl_cluster, 0) < 0)
LM_ERR("Sync request failed\n");

if (!shtags_list) {
Expand Down
2 changes: 1 addition & 1 deletion modules/dialog/dlg_replication.c
Expand Up @@ -1411,7 +1411,7 @@ static void broadcast_profiles(utime_t ticks, void *param)

struct mi_root* mi_sync_cl_dlg(struct mi_root *cmd, void *param)
{
if (clusterer_api.request_sync(&dlg_repl_cap, dialog_repl_cluster) < 0)
if (clusterer_api.request_sync(&dlg_repl_cap, dialog_repl_cluster, 1) < 0)
return init_mi_tree(400, MI_SSTR("Failed to send sync request"));
else
return init_mi_tree(200, MI_SSTR(MI_OK));
Expand Down
2 changes: 1 addition & 1 deletion modules/usrloc/ul_mi.c
Expand Up @@ -775,7 +775,7 @@ struct mi_root* mi_usrloc_cl_sync(struct mi_root *cmd, void *param)
if (!location_cluster)
return init_mi_tree(400, MI_SSTR("Clustering not enabled"));

if (clusterer_api.request_sync(&contact_repl_cap, location_cluster) < 0)
if (clusterer_api.request_sync(&contact_repl_cap, location_cluster, 1) < 0)
return init_mi_tree(400, MI_SSTR("Failed to send sync request"));
else
return init_mi_tree(200, MI_SSTR(MI_OK));
Expand Down
2 changes: 1 addition & 1 deletion modules/usrloc/ul_mod.c
Expand Up @@ -502,7 +502,7 @@ static int mod_init(void)
}

if (rr_persist == RRP_SYNC_FROM_CLUSTER &&
clusterer_api.request_sync(&contact_repl_cap, location_cluster) < 0)
clusterer_api.request_sync(&contact_repl_cap, location_cluster, 0) < 0)
LM_ERR("Sync request failed\n");
}

Expand Down

0 comments on commit 3474153

Please sign in to comment.