Browse Source

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
Daniel-Constantin Mierla 11 years ago
parent
commit
02e43f87b2
3 changed files with 19 additions and 3 deletions
  1. 8 0
      modules/dialog/dlg_handlers.c
  2. 9 2
      modules/dialog/dlg_var.c
  3. 2 1
      modules/dialog/dlg_var.h

+ 8 - 0
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;
 	}

+ 9 - 2
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);
 				}
 			}

+ 2 - 1
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 */