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

Function clusterer_bcast_msg

modules/clusterer/clusterer.c:459–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459static enum clusterer_send_ret
460clusterer_bcast_msg(bin_packet_t *packet, int dst_cid,
461 enum cl_node_match_op match_op, int check_cap)
462{
463 node_info_t *node;
464 int rc, sent = 0, down = 1, matched_once = 0;
465 cluster_info_t *dst_cl;
466 int ev_actions_required = 0;
467 str capability;
468
469 if (!cl_list_lock) {
470 LM_ERR("cluster shutdown - cannot send new messages!\n");
471 return CLUSTERER_CURR_DISABLED;
472 }
473
474 lock_start_read(cl_list_lock);
475
476 dst_cl = get_cluster_by_id(dst_cid);
477 if (!dst_cl) {
478 LM_ERR("Unknown cluster, id [%d]\n", dst_cid);
479 lock_stop_read(cl_list_lock);
480 return CLUSTERER_SEND_ERR;
481 }
482
483 lock_get(dst_cl->current_node->lock);
484 if (!(dst_cl->current_node->flags & NODE_STATE_ENABLED)) {
485 lock_release(dst_cl->current_node->lock);
486 lock_stop_read(cl_list_lock);
487 return CLUSTERER_CURR_DISABLED;
488 }
489 lock_release(dst_cl->current_node->lock);
490
491 if (check_cap) {
492 bin_get_capability(packet, &capability);
493 rc = get_capability_status(dst_cl, &capability);
494 if (rc == -1) {
495 lock_stop_read(cl_list_lock);
496 return CLUSTERER_SEND_ERR;
497 } else if (rc == CAP_DISABLED) {
498 lock_stop_read(cl_list_lock);
499 LM_DBG("capability [%.*s] disabled, skip message sending\n",
500 capability.len, capability.s);
501 return CLUSTERER_SEND_SUCCESS;
502 }
503 }
504
505 for (node = dst_cl->node_list; node; node = node->next) {
506 if (!match_node(dst_cl->current_node, node, match_op))
507 continue;
508
509 lock_get(node->lock);
510 if (!(node->flags & NODE_STATE_ENABLED)) {
511 lock_release(node->lock);
512 LM_DBG("node disabled, skip message sending\n");
513 continue;
514 }
515 lock_release(node->lock);
516

Callers 5

cl_send_allFunction · 0.85
cl_send_all_havingFunction · 0.85
bcast_gen_msgFunction · 0.85
send_mi_cmdFunction · 0.85
bcast_remove_nodeFunction · 0.85

Calls 11

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

Tested by

no test coverage detected