[sr-dev] git:master: tm: TMCB_RESPONSE_READY executes by its own

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 2 18:22:50 CEST 2010


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Jul  2 18:21:10 2010 +0200

tm: TMCB_RESPONSE_READY executes by its own

- removed the define of it to TMCB_RESPONSE_OUT
- now this callback is executed before writing reply to network

---

 modules/tm/t_hooks.h  |   16 +++++++++-------
 modules/tm/t_lookup.c |    3 ++-
 modules/tm/t_reply.c  |   19 +++++++++++++++----
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/modules/tm/t_hooks.h b/modules/tm/t_hooks.h
index 32ebaa3..38ba5d4 100644
--- a/modules/tm/t_hooks.h
+++ b/modules/tm/t_hooks.h
@@ -74,15 +74,16 @@ struct cell;
 #define TMCB_DESTROY_N          15  /* called on transaction destroy */
 #define TMCB_E2ECANCEL_IN_N     16
 #define TMCB_E2EACK_RETR_IN_N   17
+#define TMCB_RESPONSE_READY_N	18
 #ifdef WITH_AS_SUPPORT
-#define TMCB_DONT_ACK_N         18 /* TM shoudn't ACK a local UAC  */
+#define TMCB_DONT_ACK_N         19 /* TM shoudn't ACK a local UAC  */
 #endif
 #ifdef TMCB_ONSEND
-#define TMCB_REQUEST_SENT_N     19
-#define TMCB_RESPONSE_SENT_N    20
-#define TMCB_MAX_N              20
+#define TMCB_REQUEST_SENT_N     20
+#define TMCB_RESPONSE_SENT_N    21
+#define TMCB_MAX_N              21
 #else
-#define TMCB_MAX_N              18
+#define TMCB_MAX_N              19
 #endif
 
 
@@ -104,6 +105,7 @@ struct cell;
 #define TMCB_DESTROY          (1<<TMCB_DESTROY_N)
 #define TMCB_E2ECANCEL_IN     (1<<TMCB_E2ECANCEL_IN_N)
 #define TMCB_E2EACK_RETR_IN   (1<<TMCB_E2EACK_RETR_IN_N)
+#define TMCB_RESPONSE_READY   (1<<TMCB_RESPONSE_READY_N)
 #ifdef WITH_AS_SUPPORT
 #define TMCB_DONT_ACK         (1<<TMCB_DONT_ACK_N)
 #endif
@@ -113,8 +115,6 @@ struct cell;
 #endif
 #define TMCB_MAX              ((1<<(TMCB_MAX_N+1))-1)
 
-/* response ready - might need to be executed before sending reply out */
-#define TMCB_RESPONSE_READY		TMCB_RESPONSE_OUT
 
 /*
  *  Caution: most of the callbacks work with shmem-ized messages
@@ -325,6 +325,8 @@ struct cell;
  *  the cell* parameter (t) and the tmcb are set to 0. Only the param is
  *  is filled inside TMCB. For dialogs callbacks t is also 0.
  *
+ * TMCB_RESPONSE_READY -- a reply is ready to be sent out. Callback is
+ *  is executed just before writing the reply content to network.
  *
  * TMCB_DONT_ACK (requires AS support) -- for localy generated INVITEs, TM 
  * automatically generates an ACK for the received 2xx replies. But, if this 
diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c
index ff8b4c5..be65ade 100644
--- a/modules/tm/t_lookup.c
+++ b/modules/tm/t_lookup.c
@@ -1026,7 +1026,8 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 			&& p_msg->REPLY_STATUS<300 
 			&& ((!is_local(p_cell) &&
 				has_tran_tmcbs(p_cell, 
-					TMCB_RESPONSE_OUT|TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN) )
+					TMCB_RESPONSE_OUT|TMCB_RESPONSE_READY
+					|TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN) )
 			|| (is_local(p_cell)&&has_tran_tmcbs(p_cell, TMCB_LOCAL_COMPLETED))
 		)) ) {
 			if (parse_headers(p_msg, HDR_TO_F, 0)==-1) {
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 4318886..3fc4123 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -596,10 +596,16 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 	/* do UAC cleanup procedures in case we generated
 	   a final answer whereas there are pending UACs */
 	if (code>=200) {
-		if (unlikely(is_local(trans) && 
-					has_tran_tmcbs(trans, TMCB_LOCAL_COMPLETED) ))
-			run_trans_callbacks(TMCB_LOCAL_COMPLETED, trans,
+		if (unlikely(is_local(trans))) {
+			if(unlikely(has_tran_tmcbs(trans, TMCB_LOCAL_COMPLETED)))
+				run_trans_callbacks(TMCB_LOCAL_COMPLETED, trans,
 									0, FAKED_REPLY, code);
+		} else {
+			if(unlikely(has_tran_tmcbs(trans, TMCB_RESPONSE_READY))) {
+				run_trans_callbacks(TMCB_RESPONSE_READY, trans,
+					trans->uas.request, FAKED_REPLY, code);
+			}
+		}
 		cleanup_uac_timers( trans );
 		if (is_invite(trans)){
 			prepare_to_cancel(trans, &cancel_bitmap, 0);
@@ -1724,7 +1730,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		if ( unlikely(is_invite(t) && relayed_msg!=FAKED_REPLY
 		&& relayed_code>=200 && relayed_code < 300
 		&& has_tran_tmcbs( t,
-				TMCB_RESPONSE_OUT|TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN))) {
+				TMCB_RESPONSE_OUT|TMCB_RESPONSE_READY
+				|TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN))) {
 			totag_retr=update_totag_set(t, relayed_msg);
 		}
 	}; /* if relay ... */
@@ -1733,6 +1740,10 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 
 	/* send it now (from the private buffer) */
 	if (relay >= 0) {
+		if (unlikely(!totag_retr && has_tran_tmcbs(t, TMCB_RESPONSE_READY))){
+			run_trans_callbacks(TMCB_RESPONSE_READY, t,
+					t->uas.request, relayed_msg, relayed_code);
+		}
 		/* Set retransmission timer before the reply is sent out to avoid
 		* race conditions
 		*




More information about the sr-dev mailing list