[sr-dev] git:alexh/dialog-sync-wip: dialog: Do not delete replicated dialogs immediately to absorb out-of-order syncs

Alex Hermann alex at speakup.nl
Thu Sep 4 13:21:35 CEST 2014


Module: sip-router
Branch: alexh/dialog-sync-wip
Commit: aebd669c902e45cf18874feb7f5eca5ace05d536
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=aebd669c902e45cf18874feb7f5eca5ace05d536

Author: Alex Hermann <alex at speakup.nl>
Committer: Alex Hermann <alex at speakup.nl>
Date:   Thu Aug 28 11:18:56 2014 +0200

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.

---

 modules/dialog/dialog.c   |    2 +-
 modules/dialog/dlg_dmq.c  |    3 ++-
 modules/dialog/dlg_hash.c |    6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c
index b5b6321..4960ef8 100644
--- a/modules/dialog/dialog.c
+++ b/modules/dialog/dialog.c
@@ -147,7 +147,7 @@ int dlg_db_mode_param = DB_MODE_NONE;
 str dlg_xavp_cfg = {0};
 int dlg_ka_timer = 0;
 int dlg_ka_interval = 0;
-int dlg_clean_timer = 90;
+int dlg_clean_timer = 10;
 
 /* db stuff */
 static str db_url = str_init(DEFAULT_DB_URL);
diff --git a/modules/dialog/dlg_dmq.c b/modules/dialog/dlg_dmq.c
index 2f87f08..60b90d5 100644
--- a/modules/dialog/dlg_dmq.c
+++ b/modules/dialog/dlg_dmq.c
@@ -265,7 +265,8 @@ int dlg_dmq_handle_msg(struct sip_msg* msg, peer_reponse_t* resp, dmq_node_t* dm
 					}
 					/* prevent DB sync */
 					dlg->dflags |= DLG_FLAG_NEW;
-					unref++;
+					/* keep dialog around for a bit, to prevent out-of-order syncs to reestablish the dlg */
+					dlg->init_ts = time(NULL);
 					break;
 				default:
 					LM_ERR("unhandled state update to state %u\n", state);
diff --git a/modules/dialog/dlg_hash.c b/modules/dialog/dlg_hash.c
index ac869ad..b5bf6fa 100644
--- a/modules/dialog/dlg_hash.c
+++ b/modules/dialog/dlg_hash.c
@@ -252,6 +252,12 @@ int dlg_clean_run(ticks_t ti)
 						tdlg, tdlg->ref);
 				unlink_unsafe_dlg(&d_table->entries[i], tdlg);
 				destroy_dlg(tdlg);
+			} else if(tdlg->state==DLG_STATE_DELETED && tdlg->init_ts<tm-32) {
+				/* dialog in deleted state older than 32 sec */
+				LM_DBG("deleting dialog in deleted state (%p ref %d)\n",
+						tdlg, tdlg->ref);
+				unlink_unsafe_dlg(&d_table->entries[i], tdlg);
+				destroy_dlg(tdlg);
 			}
 			if(tdlg->state==DLG_STATE_CONFIRMED_NA && tdlg->start_ts<tm-60) {
 				if(update_dlg_timer(&dlg->tl, 10)<0) {




More information about the sr-dev mailing list