Skip to content

Commit

Permalink
clusterer: make sure a discovered node is not added multiple times
Browse files Browse the repository at this point in the history
Do not insert a new node into the list multiple times when:
* receiving multiple CLUSTERER_NODE_DESCRIPTION BIN messages
* we receive a CLUSTERER_NODE_DESCRIPTION message and the node also
  appears in CLUSTERER_FULL_TOP_UPDATE messages.

(cherry picked from commit b8e1075)
  • Loading branch information
rvlad-patrascu committed Jun 25, 2022
1 parent ef2ac0d commit 07a6b2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 5 additions & 0 deletions modules/clusterer/node_info.c
Expand Up @@ -110,6 +110,11 @@ int add_node_info(node_info_t **new_info, cluster_info_t **cl_list, int *int_val
*cl_list = cluster;
}

if (get_node_by_id(cluster, int_vals[INT_VALS_NODE_ID_COL])) {
LM_DBG("Node [%d] already exists\n", int_vals[INT_VALS_NODE_ID_COL]);
return 0;
}

*new_info = shm_malloc(sizeof **new_info);
if (!*new_info) {
LM_ERR("no more shm memory\n");
Expand Down
5 changes: 0 additions & 5 deletions modules/clusterer/topology.c
Expand Up @@ -698,11 +698,6 @@ static node_info_t *add_node(bin_packet_t *received, cluster_info_t *cl,
lock_switch_read(cl_list_lock, lock_old_flag);
return NULL;
}
if (!new_node) {
LM_ERR("Unable to add node info to backing list\n");
lock_switch_read(cl_list_lock, lock_old_flag);
return NULL;
}

lock_switch_read(cl_list_lock, lock_old_flag);

Expand Down

0 comments on commit 07a6b2e

Please sign in to comment.