[sr-dev] git:4.0: dialog: detect if no trasaction is created after config execution for new dialogs

Daniel-Constantin Mierla miconda at gmail.com
Sun Aug 4 15:21:35 CEST 2013


Module: sip-router
Branch: 4.0
Commit: 9f0a42dd31d765541c02d2b818dd52643589f59d
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9f0a42dd31d765541c02d2b818dd52643589f59d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Jul  2 23:32:37 2013 +0200

dialog: detect if no trasaction is created after config execution for new dialogs

- release the dialog to avoid endless storage in state 1

(cherry picked from commit fa0339b1906690f009786fc9ed92c73a8c9e6520)

---

 modules/dialog/dlg_handlers.c |   10 +++++++++-
 modules/dialog/dlg_var.c      |   14 +++++++++++++-
 modules/dialog/dlg_var.h      |    1 +
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/modules/dialog/dlg_handlers.c b/modules/dialog/dlg_handlers.c
index ec55a13..9393d7f 100644
--- a/modules/dialog/dlg_handlers.c
+++ b/modules/dialog/dlg_handlers.c
@@ -721,11 +721,14 @@ void dlg_onreq(struct cell* t, int type, struct tmcb_params *param)
 	if (dlg==NULL) {
 		if((req->flags&dlg_flag)!=dlg_flag)
 			return;
+		LM_DBG("dialog creation on config flag\n");
 		dlg_new_dialog(req, t, 1);
 		dlg = dlg_get_ctx_dialog();
 	}
 	if (dlg!=NULL) {
+		LM_DBG("dialog added to tm callbacks\n");
 		dlg_set_tm_callbacks(t, req, dlg, spiral_detected);
+		_dlg_ctx.t = 1;
 		dlg_release(dlg);
 	}
 }
@@ -1515,8 +1518,13 @@ int dlg_manage(sip_msg_t *msg)
 		dlg = dlg_get_ctx_dialog();
 		if(dlg==NULL)
 			return -1;
-		if(t!=NULL)
+		if(t!=NULL) {
 			dlg_set_tm_callbacks(t, msg, dlg, spiral_detected);
+			_dlg_ctx.t = 1;
+			LM_DBG("dialog created on existing transaction\n");
+		} else {
+			LM_DBG("dialog created before transaction\n");
+		}
 		dlg_release(dlg);
 	}
 	return 1;
diff --git a/modules/dialog/dlg_var.c b/modules/dialog/dlg_var.c
index 108af0f..0d8a1c7 100644
--- a/modules/dialog/dlg_var.c
+++ b/modules/dialog/dlg_var.c
@@ -22,6 +22,7 @@
  */
 		       
 #include "../../route.h"
+#include "../../script_cb.h"
 #include "../../pvapi.h"
 
 #include "dlg_var.h"
@@ -38,8 +39,19 @@ struct dlg_var * var_table = 0;
 /*! ID of the current message */
 int msg_id;
 
-int dlg_cfg_cb(struct sip_msg *foo, unsigned int flags, void *bar)
+int dlg_cfg_cb(sip_msg_t *msg, unsigned int flags, void *cbp)
 {
+	dlg_cell_t *dlg;
+	if(flags&POST_SCRIPT_CB) {
+		dlg = dlg_get_ctx_dialog();
+		if(dlg!=NULL) {
+			if(_dlg_ctx.t==0 && dlg->state==DLG_STATE_UNCONFIRMED) {
+				LM_DBG("new dialog with no trasaction after config execution\n");
+				dlg_release(dlg);
+			}
+			dlg_release(dlg);
+		}
+	}
 	memset(&_dlg_ctx, 0, sizeof(dlg_ctx_t));
 
 	return 1;
diff --git a/modules/dialog/dlg_var.h b/modules/dialog/dlg_var.h
index 9648ab2..ec2c9c7 100644
--- a/modules/dialog/dlg_var.h
+++ b/modules/dialog/dlg_var.h
@@ -41,6 +41,7 @@ typedef struct _dlg_ctx {
 	dlg_iuid_t iuid;
 	int set;
 	unsigned int dir;
+	int t;
 } dlg_ctx_t;
 
 /* A dialog-variable */




More information about the sr-dev mailing list