瀏覽代碼

- tm: a valid msg->hash_index is now marked by the FL_HASH_INDEX flag
in msg->msg_flags (previously a buggy 0-compariosn was used)
- tm: t_lookupOriginalT will compute msg->hash_index by itself if needed
(old version required a previous t_check call)
- tm/core: check_transaction_quadruple inlined

Andrei Pelinescu-Onciul 19 年之前
父節點
當前提交
0575e3b1a1
共有 3 個文件被更改,包括 40 次插入19 次删除
  1. 20 2
      modules/tm/t_lookup.c
  2. 0 16
      parser/msg_parser.c
  3. 20 1
      parser/msg_parser.h

+ 20 - 2
modules/tm/t_lookup.c

@@ -84,6 +84,10 @@
  *             if the searched transaction was pre-canceled (andrei)
  * 2006-10-16  401 & 407 replies are completely parsed if tm_aggregate_auth is
  *              set (andrei)
+ * 2006-11-10  a valid msg->hash_index is now marked by FL_HASH_INDEX in 
+ *              msg_flags
+ *             t_lookupOriginalT computes the hash_index by itself  if 
+*               needed (andrei)
  */
 
 #include "defs.h"
@@ -416,8 +420,10 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked,
 	}
 
 	/* start searching into the table */
-	if (!p_msg->hash_index)
-		p_msg->hash_index=hash( p_msg->callid->body , get_cseq(p_msg)->number ) ;
+	if (!(p_msg->msg_flags & FL_HASH_INDEX)){
+		p_msg->hash_index=hash( p_msg->callid->body , get_cseq(p_msg)->number);
+		p_msg->msg_flags|=FL_HASH_INDEX;
+	}
 	isACK = p_msg->REQ_METHOD==METHOD_ACK;
 	DBG("t_lookup_request: start searching: hash=%d, isACK=%d\n",
 		p_msg->hash_index,isACK);
@@ -606,6 +612,18 @@ struct cell* t_lookupOriginalT(  struct sip_msg* p_msg )
 
 
 	/* start searching in the table */
+	if (!(p_msg->msg_flags & FL_HASH_INDEX)){
+		/* parse all*/
+		if (check_transaction_quadruple(p_msg)==0)
+		{
+			LOG(L_ERR, "ERROR: TM module: t_lookupOriginalT:"
+					" too few headers\n");
+			/* stop processing */
+			return 0;
+		}
+		p_msg->hash_index=hash( p_msg->callid->body , get_cseq(p_msg)->number);
+		p_msg->msg_flags|=FL_HASH_INDEX;
+	}
 	hash_index = p_msg->hash_index;
 	DBG("DEBUG: t_lookupOriginalT: searching on hash entry %d\n",hash_index );
 

+ 0 - 16
parser/msg_parser.c

@@ -660,22 +660,6 @@ void free_sip_msg(struct sip_msg* msg)
 }
 
 
-/* make sure all HFs needed for transaction identification have been
-   parsed; return 0 if those HFs can't be found
-*/
-
-int check_transaction_quadruple( struct sip_msg* msg )
-{
-	if ( parse_headers(msg, HDR_FROM_F|HDR_TO_F|HDR_CALLID_F|HDR_CSEQ_F,0)!=-1
-		&& msg->from && msg->to && msg->callid && msg->cseq ) {
-		return 1;
-	} else {
-		ser_error=E_BAD_TUPEL;
-		return 0;
-	}
-}
-
-
 /*
  * Make a private copy of the string and assign it to dst_uri
  */

+ 20 - 1
parser/msg_parser.h

@@ -39,12 +39,14 @@
  *  2004-11-08  added force_send_socket (andrei)
  *  2005-02-25  uri types added (sip, sips & tel)  (andrei)
  *  2006-04-20  uri comp member (only if USE_COMP is defined) (andrei)
+ *  2006-11-10  check_transaction_quadruple inlined (andrei)
  */
 
 
 #ifndef msg_parser_h
 #define msg_parser_h
 
+
 #include "../comp_defs.h"
 #include "../str.h"
 #include "../lump_struct.h"
@@ -58,6 +60,7 @@
 #include "parse_via.h"
 #include "parse_fline.h"
 #include "hf.h"
+#include "../error.h"
 
 
 /* convenience short-cut macros */
@@ -80,6 +83,7 @@ enum request_method { METHOD_UNDEF=0, METHOD_INVITE=1, METHOD_CANCEL=2, METHOD_A
                                (for failure route use) */
 #define FL_REPLIED     64  /* message branch received at least one reply
                                 (for failure route use) */
+#define FL_HASH_INDEX  128 /* msg->hash_index contains a valid value (tm use)*/
 
 
 #define IFISMETHOD(methodname,firstchar)                                  \
@@ -286,7 +290,22 @@ void free_sip_msg(struct sip_msg* msg);
    parsed; return 0 if those HFs can't be found
  */
 
-int check_transaction_quadruple( struct sip_msg* msg );
+
+/* make sure all HFs needed for transaction identification have been
+   parsed; return 0 if those HFs can't be found
+*/
+inline static int check_transaction_quadruple( struct sip_msg* msg )
+{
+	if ( parse_headers(msg, HDR_FROM_F|HDR_TO_F|HDR_CALLID_F|HDR_CSEQ_F,0)!=-1
+		&& msg->from && msg->to && msg->callid && msg->cseq ) {
+		return 1;
+	} else {
+		ser_error=E_BAD_TUPEL;
+		return 0;
+	}
+}
+
+
 
 /* calculate characteristic value of a message -- this value
    is used to identify a transaction during the process of