Browse code

dialog: Do not delete replicated dialogs immediately to absorb out-of-order syncs

Use a timer to cleanup dlgs in "deleted" state. This gives a limited timeframe
to prevent out-of-sync state changes.

Alex Hermann authored on 28/08/2014 09:18:56
Showing 3 changed files
... ...
@@ -147,7 +147,7 @@ int dlg_db_mode_param = DB_MODE_NONE;
147 147
 str dlg_xavp_cfg = {0};
148 148
 int dlg_ka_timer = 0;
149 149
 int dlg_ka_interval = 0;
150
-int dlg_clean_timer = 90;
150
+int dlg_clean_timer = 10;
151 151
 
152 152
 /* db stuff */
153 153
 static str db_url = str_init(DEFAULT_DB_URL);
... ...
@@ -265,7 +265,8 @@ int dlg_dmq_handle_msg(struct sip_msg* msg, peer_reponse_t* resp, dmq_node_t* dm
265 265
 					}
266 266
 					/* prevent DB sync */
267 267
 					dlg->dflags |= DLG_FLAG_NEW;
268
-					unref++;
268
+					/* keep dialog around for a bit, to prevent out-of-order syncs to reestablish the dlg */
269
+					dlg->init_ts = time(NULL);
269 270
 					break;
270 271
 				default:
271 272
 					LM_ERR("unhandled state update to state %u\n", state);
... ...
@@ -252,6 +252,12 @@ int dlg_clean_run(ticks_t ti)
252 252
 						tdlg, tdlg->ref);
253 253
 				unlink_unsafe_dlg(&d_table->entries[i], tdlg);
254 254
 				destroy_dlg(tdlg);
255
+			} else if(tdlg->state==DLG_STATE_DELETED && tdlg->init_ts<tm-32) {
256
+				/* dialog in deleted state older than 32 sec */
257
+				LM_DBG("deleting dialog in deleted state (%p ref %d)\n",
258
+						tdlg, tdlg->ref);
259
+				unlink_unsafe_dlg(&d_table->entries[i], tdlg);
260
+				destroy_dlg(tdlg);
255 261
 			}
256 262
 			if(tdlg->state==DLG_STATE_CONFIRMED_NA && tdlg->start_ts<tm-60) {
257 263
 				if(update_dlg_timer(&dlg->tl, 10)<0) {