@@ -48,6 +48,11 @@ str shtag_dlg_val = str_init("dlgX_shtag");
48
48
char * dlg_sync_in_progress ;
49
49
50
50
static int get_shtag_sync_status (struct dlg_cell * dlg );
51
+ /*
52
+ * indicates whether the dialog is in the process of receiving a replicated
53
+ * dialog (update) - used to avoid cross-replicating the same value
54
+ */
55
+ static int dlg_event_is_replicated = 0 ;
51
56
52
57
const static struct socket_info * fetch_socket_info (str * addr )
53
58
{
@@ -744,10 +749,16 @@ int dlg_replicated_value(bin_packet_t *packet)
744
749
DLG_BIN_POP (int , packet , h_id , malformed );
745
750
DLG_BIN_POP (str , packet , name , malformed );
746
751
DLG_BIN_POP (int , packet , type , malformed );
747
- if (type == DLG_VAL_TYPE_STR )
748
- DLG_BIN_POP (str , packet , val .s , malformed );
749
- else
750
- DLG_BIN_POP (int , packet , val .n , malformed );
752
+ switch (type ) {
753
+ case DLG_VAL_TYPE_STR :
754
+ DLG_BIN_POP (str , packet , val .s , malformed );
755
+ break ;
756
+ case DLG_VAL_TYPE_INT :
757
+ DLG_BIN_POP (int , packet , val .n , malformed );
758
+ break ;
759
+ default :
760
+ break ;
761
+ }
751
762
752
763
LM_DBG ("Updating cseq for dialog with callid: %.*s\n" , call_id .len , call_id .s );
753
764
h_entry = dlg_hash (& call_id );
@@ -1045,6 +1056,9 @@ void replicate_dialog_value(struct dlg_cell *dlg, str *name, int_str *val, int t
1045
1056
{
1046
1057
bin_packet_t packet ;
1047
1058
1059
+ if (dlg_event_is_replicated )
1060
+ return ;
1061
+
1048
1062
if (bin_init (& packet , & dlg_repl_cap , REPLICATION_DLG_VALUE ,
1049
1063
BIN_VERSION , 512 ) != 0 )
1050
1064
goto error ;
@@ -1053,10 +1067,18 @@ void replicate_dialog_value(struct dlg_cell *dlg, str *name, int_str *val, int t
1053
1067
bin_push_int (& packet , dlg -> h_id );
1054
1068
bin_push_str (& packet , name );
1055
1069
bin_push_int (& packet , type );
1056
- if (type == DLG_VAL_TYPE_STR )
1057
- bin_push_str (& packet , & val -> s );
1058
- else
1059
- bin_push_int (& packet , val -> n );
1070
+ if (!val )
1071
+ type = DLG_VAL_TYPE_NONE ;
1072
+ switch (type ) {
1073
+ case DLG_VAL_TYPE_STR :
1074
+ bin_push_str (& packet , & val -> s );
1075
+ break ;
1076
+ case DLG_VAL_TYPE_INT :
1077
+ bin_push_int (& packet , val -> n );
1078
+ break ;
1079
+ default :
1080
+ break ;
1081
+ }
1060
1082
1061
1083
DLG_CLUSTER_SEND (packet , dialog_repl_cluster , error_free );
1062
1084
@@ -1081,41 +1103,48 @@ void receive_dlg_repl(bin_packet_t *pkt)
1081
1103
if (ver != DLG_BIN_V3 )
1082
1104
ensure_bin_version (pkt , BIN_VERSION );
1083
1105
1106
+ dlg_event_is_replicated = 1 ;
1084
1107
rc = dlg_replicated_create (pkt , NULL , NULL , NULL , 0 , 0 , 0 );
1085
1108
if_update_stat (dlg_enable_stats , create_recv , 1 );
1086
1109
break ;
1087
1110
case REPLICATION_DLG_UPDATED :
1088
1111
if (ver != DLG_BIN_V3 )
1089
1112
ensure_bin_version (pkt , BIN_VERSION );
1090
1113
1114
+ dlg_event_is_replicated = 1 ;
1091
1115
rc = dlg_replicated_update (pkt );
1092
1116
if_update_stat (dlg_enable_stats , update_recv , 1 );
1093
1117
break ;
1094
1118
case REPLICATION_DLG_DELETED :
1095
1119
if (ver != DLG_BIN_V3 )
1096
1120
ensure_bin_version (pkt , BIN_VERSION );
1097
1121
1122
+ dlg_event_is_replicated = 1 ;
1098
1123
rc = dlg_replicated_delete (pkt );
1099
1124
if_update_stat (dlg_enable_stats , delete_recv , 1 );
1100
1125
break ;
1101
1126
case REPLICATION_DLG_CSEQ :
1102
1127
if (ver != DLG_BIN_V3 )
1103
1128
ensure_bin_version (pkt , BIN_VERSION );
1104
1129
1130
+ dlg_event_is_replicated = 1 ;
1105
1131
rc = dlg_replicated_cseq_updated (pkt );
1106
1132
break ;
1107
1133
case REPLICATION_DLG_VALUE :
1108
1134
ensure_bin_version (pkt , BIN_VERSION );
1109
1135
1136
+ dlg_event_is_replicated = 1 ;
1110
1137
rc = dlg_replicated_value (pkt );
1111
1138
break ;
1112
1139
case SYNC_PACKET_TYPE :
1113
1140
if (ver != DLG_BIN_V3 )
1114
1141
ensure_bin_version (pkt , BIN_VERSION );
1115
1142
1143
+ dlg_event_is_replicated = 1 ;
1116
1144
while (clusterer_api .sync_chunk_iter (pkt ))
1117
1145
if (dlg_replicated_create (pkt , NULL , NULL , NULL , 0 , 0 , 1 ) < 0 ) {
1118
1146
LM_ERR ("Failed to process sync packet\n" );
1147
+ dlg_event_is_replicated = 0 ;
1119
1148
return ;
1120
1149
}
1121
1150
break ;
@@ -1128,6 +1157,7 @@ void receive_dlg_repl(bin_packet_t *pkt)
1128
1157
1129
1158
if (rc != 0 )
1130
1159
LM_ERR ("Failed to process a binary packet!\n" );
1160
+ dlg_event_is_replicated = 0 ;
1131
1161
}
1132
1162
1133
1163
static int receive_sync_request (int node_id )
0 commit comments