MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / clusterer_send_msg

Function clusterer_send_msg

modules/clusterer/clusterer.c:361–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361enum clusterer_send_ret clusterer_send_msg(bin_packet_t *packet,
362 int cluster_id, int dst_node_id, int check_cap, int locked)
363{
364 node_info_t *node;
365 int rc;
366 cluster_info_t *cl;
367 int ev_actions_required = 0;
368 str capability;
369
370 if (!cl_list_lock) {
371 LM_ERR("cluster shutdown - cannot send new messages!\n");
372 return CLUSTERER_CURR_DISABLED;
373 }
374 if (!locked)
375 lock_start_read(cl_list_lock);
376
377 cl = get_cluster_by_id(cluster_id);
378 if (!cl) {
379 LM_ERR("Unknown cluster id [%d]\n", cluster_id);
380 if (!locked)
381 lock_stop_read(cl_list_lock);
382 return CLUSTERER_SEND_ERR;
383 }
384
385 lock_get(cl->current_node->lock);
386 if (!(cl->current_node->flags & NODE_STATE_ENABLED)) {
387 lock_release(cl->current_node->lock);
388 if (!locked)
389 lock_stop_read(cl_list_lock);
390 return CLUSTERER_CURR_DISABLED;
391 }
392 lock_release(cl->current_node->lock);
393
394 if (dst_node_id == cl->current_node->node_id) {
395 node = cl->current_node;
396 } else {
397 node = get_node_by_id(cl, dst_node_id);
398 if (!node) {
399 LM_ERR("Node id [%d] not found in cluster\n", dst_node_id);
400 if (!locked)
401 lock_stop_read(cl_list_lock);
402 return CLUSTERER_SEND_ERR;
403 }
404 }
405
406 lock_get(node->lock);
407 if (!(node->flags & NODE_STATE_ENABLED)) {
408 lock_release(node->lock);
409 lock_stop_read(cl_list_lock);
410 LM_DBG("node disabled, skip message sending\n");
411 return CLUSTERER_SEND_SUCCESS;
412 }
413 lock_release(node->lock);
414
415 if (check_cap) {
416 bin_get_capability(packet, &capability);
417 rc = get_capability_status(cl, &capability);
418 if (rc == -1) {

Callers 6

send_sync_reqFunction · 0.85
send_sync_replFunction · 0.85
cl_send_toFunction · 0.85
send_gen_msgFunction · 0.85
send_mi_cmdFunction · 0.85
shtag_send_active_infoFunction · 0.85

Calls 11

get_cluster_by_idFunction · 0.85
lock_getFunction · 0.85
lock_releaseFunction · 0.85
get_node_by_idFunction · 0.85
bin_get_capabilityFunction · 0.85
get_capability_statusFunction · 0.85
bin_push_intFunction · 0.85
handle_cl_gen_msgFunction · 0.85
msg_send_retryFunction · 0.85
do_actions_node_evFunction · 0.85

Tested by

no test coverage detected