Skip to content

Commit

Permalink
clusterer: prevent crash when calling send_to after destroy
Browse files Browse the repository at this point in the history
(cherry picked from commit 5928e46)
  • Loading branch information
razvancrainea committed Jun 30, 2017
1 parent 8025792 commit 2c9d860
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions modules/clusterer/clusterer.c
Expand Up @@ -677,6 +677,10 @@ enum clusterer_send_ret cl_send_to(bin_packet_t *packet, int cluster_id, int nod
cluster_info_t *cl;
int check_call_cbs_event = 0;

if (!cl_list_lock) {
LM_ERR("cluster shutdown - cannot send new messages!\n");
return CLUSTERER_CURR_DISABLED;
}
lock_start_read(cl_list_lock);

cl = get_cluster_by_id(cluster_id);
Expand Down Expand Up @@ -732,6 +736,10 @@ enum clusterer_send_ret cl_send_all(bin_packet_t *packet, int cluster_id)
cluster_info_t *cl;
int check_call_cbs_event = 0;

if (!cl_list_lock) {
LM_ERR("cluster shutdown - cannot send new messages!\n");
return CLUSTERER_CURR_DISABLED;
}
lock_start_read(cl_list_lock);

cl = get_cluster_by_id(cluster_id);
Expand Down
4 changes: 3 additions & 1 deletion modules/clusterer/clusterer_mod.c
Expand Up @@ -573,8 +573,10 @@ static void destroy(void)
}

/* destroy lock */
if (cl_list_lock)
if (cl_list_lock) {
lock_destroy_rw(cl_list_lock);
cl_list_lock = NULL;
}
}

int load_clusterer(struct clusterer_binds *binds)
Expand Down

0 comments on commit 2c9d860

Please sign in to comment.