Преглед изворни кода

- update of script callbacks registration
- TM doesn't use for replies the post-script cb for unref; it's done directly in TM reply processing function

Bogdan-Andrei Iancu пре 20 година
родитељ
комит
7bda5150cb
2 измењених фајлова са 23 додато и 16 уклоњено
  1. 3 0
      modules/tm/t_reply.c
  2. 20 16
      modules/tm/tm.c

+ 3 - 0
modules/tm/t_reply.c

@@ -1342,6 +1342,9 @@ int reply_received( struct sip_msg  *p_msg )
 	} /* provisional replies */
 
 done:
+	/* we are done with the transaction, so unref it - the reference
+	 * was incremented by t_check() function -bogdan*/
+	t_unref(p_msg);
 	/* don't try to relay statelessly neither on success
        (we forwarded statefully) nor on error; on troubles, 
 	   simply do nothing; that will make the other party to 

+ 20 - 16
modules/tm/tm.c

@@ -421,18 +421,16 @@ static int script_init( struct sip_msg *foo, void *bar)
 	 * private values left over from previous message will
 	 * not be used again */
 
-	if (foo->first_line.type==SIP_REQUEST){
-		/* make sure the new message will not inherit previous
-			message's t_on_negative value
-		*/
-		t_on_negative( 0 );
-		t_on_reply(0);
-		/* reset the kr status */
-		set_kr(0);
-		/* set request mode so that multiple-mode actions know
-		 * how to behave */
-		rmode=MODE_REQUEST;
-	}
+	/* make sure the new message will not inherit previous
+		message's t_on_negative value
+	*/
+	t_on_negative( 0 );
+	t_on_reply(0);
+	/* reset the kr status */
+	set_kr(0);
+	/* set request mode so that multiple-mode actions know
+	 * how to behave */
+	rmode=MODE_REQUEST;
 	return 1;
 }
 
@@ -540,10 +538,16 @@ static int mod_init(void)
 	}
 
 	/* register post-script clean-up function */
-	register_script_cb( w_t_unref, POST_SCRIPT_CB, 
-			0 /* empty param */ );
-	register_script_cb( script_init, PRE_SCRIPT_CB , 
-			0 /* empty param */ );
+	if (register_script_cb( w_t_unref, POST_SCRIPT_CB|REQ_TYPE_CB, 0)<0 ) {
+		LOG(L_ERR,"ERROR:tm:mod_init: failed to register POST request "
+			"callback\n");
+		return -1;
+	}
+	if (register_script_cb( script_init, PRE_SCRIPT_CB|REQ_TYPE_CB , 0)<0 ) {
+		LOG(L_ERR,"ERROR:tm:mod_init: failed to register PRE request "
+			"callback\n");
+		return -1;
+	}
 
 	init_avp_params();