[sr-dev] git:master: dialog: check if the transaction is created for BYE closing the dialog

Daniel-Constantin Mierla miconda at gmail.com
Tue Sep 16 19:07:58 CEST 2014


Module: sip-router
Branch: master
Commit: 02e43f87b2fa3be61bc4c63a9f8359457e3e0484
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=02e43f87b2fa3be61bc4c63a9f8359457e3e0484

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Sep 16 19:05:57 2014 +0200

dialog: check if the transaction is created for BYE closing the dialog

- if not, release the dialog, because there will be no tm callbacks
  called later to release it. In this way avoid zombie dialog.
- reported by Ovidiu Sas, FS#424

---

 modules/dialog/dlg_handlers.c |    8 ++++++++
 modules/dialog/dlg_var.c      |   11 +++++++++--
 modules/dialog/dlg_var.h      |    3 ++-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/modules/dialog/dlg_handlers.c b/modules/dialog/dlg_handlers.c
index 5a90d71..16c711f 100644
--- a/modules/dialog/dlg_handlers.c
+++ b/modules/dialog/dlg_handlers.c
@@ -713,6 +713,11 @@ void dlg_onreq(struct cell* t, int type, struct tmcb_params *param)
 	sip_msg_t *req = param->req;
 	dlg_cell_t *dlg = NULL;
 
+	if(req->first_line.u.request.method_value == METHOD_BYE) {
+		_dlg_ctx.t = 1;
+		return;
+	}
+
 	if(req->first_line.u.request.method_value != METHOD_INVITE)
 		return;
 
@@ -1303,6 +1308,9 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 
 		dlg_unref(dlg, unref);
 
+		_dlg_ctx.cpid = my_pid();
+		_dlg_ctx.expect_t = 1;
+
 		if_update_stat( dlg_enable_stats, active_dlgs, -1);
 		goto done;
 	}
diff --git a/modules/dialog/dlg_var.c b/modules/dialog/dlg_var.c
index 5d82777..c61cb7f 100644
--- a/modules/dialog/dlg_var.c
+++ b/modules/dialog/dlg_var.c
@@ -45,11 +45,18 @@ int dlg_cfg_cb(sip_msg_t *msg, unsigned int flags, void *cbp)
 	if(flags&POST_SCRIPT_CB) {
 		dlg = dlg_get_ctx_dialog();
 		if(dlg!=NULL) {
-			if(_dlg_ctx.t==0 && dlg->state==DLG_STATE_UNCONFIRMED) {
+			if(_dlg_ctx.t==0 && (dlg->state==DLG_STATE_UNCONFIRMED
+						|| _dlg_ctx.expect_t==1)) {
 				if(_dlg_ctx.cpid!=0 && _dlg_ctx.cpid==my_pid()) {
 					/* release to destroy dialog if created by this process
 					 * and request was not forwarded */
-					LM_DBG("new dialog with no trasaction after config execution\n");
+					if(dlg->state==DLG_STATE_UNCONFIRMED) {
+						LM_DBG("new dialog with no trasaction after config"
+									" execution\n");
+					} else {
+						LM_DBG("dialog with no expected trasaction after"
+								" config execution\n");
+					}
 					dlg_release(dlg);
 				}
 			}
diff --git a/modules/dialog/dlg_var.h b/modules/dialog/dlg_var.h
index bb604b7..a8b43cd 100644
--- a/modules/dialog/dlg_var.h
+++ b/modules/dialog/dlg_var.h
@@ -42,7 +42,8 @@ typedef struct _dlg_ctx {
 	int cpid;
 	int set;
 	unsigned int dir;
-	int t;
+	int t;				/* set to 1 if tm req in callback executed */
+	int expect_t;		/* set to 1 if expects that t is set after config */
 } dlg_ctx_t;
 
 /* A dialog-variable */




More information about the sr-dev mailing list