@@ -60,6 +60,8 @@ extern int clusterer_enable_rerouting;
60
60
61
61
int dispatch_jobs = 1 ;
62
62
63
+ void handle_cl_gen_msg (bin_packet_t * packet , int cluster_id , int source_id );
64
+
63
65
str cap_sr_details_str [] = {
64
66
str_init ("not synced" ),
65
67
str_init ("sync pending" ),
@@ -392,12 +394,16 @@ enum clusterer_send_ret clusterer_send_msg(bin_packet_t *packet,
392
394
}
393
395
lock_release (cl -> current_node -> lock );
394
396
395
- node = get_node_by_id (cl , dst_node_id );
396
- if (!node ) {
397
- LM_ERR ("Node id [%d] not found in cluster\n" , dst_node_id );
398
- if (!locked )
399
- lock_stop_read (cl_list_lock );
400
- return CLUSTERER_SEND_ERR ;
397
+ if (dst_node_id == cl -> current_node -> node_id ) {
398
+ node = cl -> current_node ;
399
+ } else {
400
+ node = get_node_by_id (cl , dst_node_id );
401
+ if (!node ) {
402
+ LM_ERR ("Node id [%d] not found in cluster\n" , dst_node_id );
403
+ if (!locked )
404
+ lock_stop_read (cl_list_lock );
405
+ return CLUSTERER_SEND_ERR ;
406
+ }
401
407
}
402
408
403
409
lock_get (node -> lock );
@@ -422,7 +428,16 @@ enum clusterer_send_ret clusterer_send_msg(bin_packet_t *packet,
422
428
}
423
429
}
424
430
425
- rc = msg_send_retry (packet , node , 0 , & ev_actions_required );
431
+ if (node == cl -> current_node && packet -> type == CLUSTERER_GENERIC_MSG ) {
432
+ bin_remove_int_buffer_end (packet , 1 );
433
+ bin_push_int (packet , node -> node_id );
434
+ bin_get_capability (packet , & capability );
435
+ packet -> front_pointer = capability .s + capability .len + CMD_FIELD_SIZE ;
436
+ handle_cl_gen_msg (packet , cluster_id , node -> node_id );
437
+ rc = 0 ;
438
+ } else {
439
+ rc = msg_send_retry (packet , node , 0 , & ev_actions_required );
440
+ }
426
441
427
442
bin_remove_int_buffer_end (packet , 3 );
428
443
@@ -510,6 +525,17 @@ clusterer_bcast_msg(bin_packet_t *packet, int dst_cid,
510
525
sent = 1 ;
511
526
}
512
527
528
+ if (match_op == NODE_CMP_ALL && packet -> type == CLUSTERER_GENERIC_MSG ) {
529
+ LM_DBG ("broadcasting gen to self (cl: %d, node: %d)\n" ,
530
+ dst_cid , dst_cl -> current_node -> node_id );
531
+ bin_remove_int_buffer_end (packet , 1 );
532
+ bin_push_int (packet , dst_cl -> current_node -> node_id );
533
+ bin_get_capability (packet , & capability );
534
+ packet -> front_pointer = capability .s + capability .len + CMD_FIELD_SIZE ;
535
+
536
+ handle_cl_gen_msg (packet , dst_cid , dst_cl -> current_node -> node_id );
537
+ }
538
+
513
539
bin_remove_int_buffer_end (packet , 3 );
514
540
515
541
if (ev_actions_required )
@@ -615,7 +641,8 @@ enum clusterer_send_ret send_gen_msg(int cluster_id, int dst_id, str *gen_msg,
615
641
return rc ;
616
642
}
617
643
618
- enum clusterer_send_ret bcast_gen_msg (int cluster_id , str * gen_msg , str * exchg_tag )
644
+ enum clusterer_send_ret bcast_gen_msg (int cluster_id , str * gen_msg ,
645
+ str * exchg_tag , int all )
619
646
{
620
647
bin_packet_t packet ;
621
648
int rc ;
@@ -626,7 +653,8 @@ enum clusterer_send_ret bcast_gen_msg(int cluster_id, str *gen_msg, str *exchg_t
626
653
return CLUSTERER_SEND_ERR ;
627
654
}
628
655
629
- rc = clusterer_bcast_msg (& packet , cluster_id , NODE_CMP_ANY , 0 );
656
+ rc = clusterer_bcast_msg (& packet , cluster_id ,
657
+ all ? NODE_CMP_ALL : NODE_CMP_ANY , 0 );
630
658
631
659
bin_free_packet (& packet );
632
660
@@ -940,7 +968,7 @@ static void handle_internal_msg(bin_packet_t *received, int packet_type,
940
968
}
941
969
}
942
970
943
- static void handle_cl_gen_msg (bin_packet_t * packet , int cluster_id , int source_id )
971
+ void handle_cl_gen_msg (bin_packet_t * packet , int cluster_id , int source_id )
944
972
{
945
973
int req_like ;
946
974
str rcv_msg , rcv_tag ;
0 commit comments