Przeglądaj źródła

- port from opensips, r4496, Credits goes to Bogdan
- for sequential requests, the dialog lifetime is not update only if explicitly
set from the script. This will avoid overwritting an initial custom lifetime
with the default lifetime, during a sequential request.
Reported by Kobi Eshun.


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4592 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 17 lat temu
rodzic
commit
6cec4124ee
1 zmienionych plików z 31 dodań i 28 usunięć
  1. 31 28
      modules_k/dialog/dlg_handlers.c

+ 31 - 28
modules_k/dialog/dlg_handlers.c

@@ -397,7 +397,7 @@ inline static int get_dlg_timeout(struct sip_msg *req)
 	&& pv_val.flags&PV_VAL_INT && pv_val.ri>0 ) {
 		return pv_val.ri;
 	}
-	LM_INFO("invalid AVP value, use default timeout");
+	LM_DBG("invalid AVP value, use default timeout");
 	return default_timeout;
 }
 
@@ -577,6 +577,7 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 	int old_state;
 	int unref;
 	int event;
+	int timeout;
 	unsigned int dir;
 
 	dlg = 0;
@@ -680,35 +681,37 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 	if ( (event==DLG_EVENT_REQ || event==DLG_EVENT_REQACK)
 	&& new_state==DLG_STATE_CONFIRMED) {
 		LM_DBG("sequential request successfully processed\n");
-		dlg->lifetime = get_dlg_timeout(req);
-		if (update_dlg_timer( &dlg->tl, dlg->lifetime )!=-1) {
-
-			if (update_cseqs(dlg, req, dir)!=0) {
-				LM_ERR("cseqs update failed\n");
-			} else {
-				dlg->flags |= DLG_FLAG_CHANGED;
-				if ( dlg_db_mode==DB_MODE_REALTIME )
-					update_dialog_dbinfo(dlg);
-			}
+		timeout = get_dlg_timeout(req);
+		/* update timer during sequential request? */
+		if (timeout!=default_timeout) {
+			dlg->lifetime = timeout;
+			if (update_dlg_timer( &dlg->tl, dlg->lifetime )==-1)
+				LM_ERR("failed to update dialog lifetime\n");
+		}
+		if (update_cseqs(dlg, req, dir)!=0) {
+			LM_ERR("cseqs update failed\n");
+		} else {
+			dlg->flags |= DLG_FLAG_CHANGED;
+			if ( dlg_db_mode==DB_MODE_REALTIME )
+				update_dialog_dbinfo(dlg);
+		}
 
-			/* within dialog request */
-			run_dlg_callbacks( DLGCB_REQ_WITHIN, dlg, req, dir, 0);
-
-			if ( (event!=DLG_EVENT_REQACK) &&
-			(dlg->cbs.types)&DLGCB_RESPONSE_WITHIN ) {
-				/* ref the dialog as registered into the transaction
-				 * callback; unref will be done when the transaction
-				 * will be destroied */
-				ref_dlg( dlg , 1);
-				/* register callback for the replies of this request */
-				if ( d_tmb.register_tmcb( req, 0, 
-				 TMCB_RESPONSE_FWDED|TMCB_TRANS_DELETED,
-				 (dir==DLG_DIR_UPSTREAM)?
-				     dlg_seq_down_onreply:dlg_seq_up_onreply,
-				 (void*)dlg)<0 ) {
-					LM_ERR("failed to register TMCB (2)\n");
+		/* within dialog request */
+		run_dlg_callbacks( DLGCB_REQ_WITHIN, dlg, req, dir, 0);
+
+		if ( (event!=DLG_EVENT_REQACK) &&
+		(dlg->cbs.types)&DLGCB_RESPONSE_WITHIN ) {
+			/* ref the dialog as registered into the transaction
+			 * callback; unref will be done when the transaction
+			 * will be destroied */
+			ref_dlg( dlg , 1);
+			/* register callback for the replies of this request */
+			if ( d_tmb.register_tmcb( req, 0, 
+			TMCB_RESPONSE_FWDED|TMCB_TRANS_DELETED,
+			(dir==DLG_DIR_UPSTREAM)?dlg_seq_down_onreply:dlg_seq_up_onreply,
+			(void*)dlg)<0 ) {
+				LM_ERR("failed to register TMCB (2)\n");
 					unref_dlg( dlg , 1);
-				}
 			}
 		}
 	}