Browse Source

t_reply_matching finalized

Jiri Kuthan 24 years ago
parent
commit
31c86f5f3d
4 changed files with 43 additions and 29 deletions
  1. 1 0
      modules/tm/TODO
  2. 2 1
      modules/tm/lock.c
  3. 20 8
      modules/tm/t_funcs.c
  4. 20 20
      parser_f.h

+ 1 - 0
modules/tm/TODO

@@ -25,3 +25,4 @@ To improve:
 - faster syncing
 
 Double-check: revire the T-state-machine
+To-do: semaphore clean-up on exit (even better: w/sibling check)

+ 2 - 1
modules/tm/lock.c

@@ -161,8 +161,9 @@ void lock_cleanup()
 		LOG(L_ERR, "ERROR: lock_cleanup, transaction_timer_semaphore cleanup failed\n");
 	if (retrasmission_timer_semaphore > 0 &&
 	    semctl( retrasmission_timer_semaphore, 0 , IPC_RMID , 0 )==-1)
-		DBG("ERROR: retrasmission_timer_semaphore cleanup failed\n"); 
 		LOG(L_ERR, "ERROR: lock_cleanup, retrasmission_timer_semaphore cleanup failed\n");
+
+	entry_semaphore = transaction_timer_semaphore = retrasmission_timer_semaphore = 0;
 	
 }
 

+ 20 - 8
modules/tm/t_funcs.c

@@ -568,17 +568,17 @@ int str_unsigned_hex_2_int( char *c, int len )
 	int r=0;
 	int i;
 	int d;
-	
+
 	for (i=0; i<len; i++ ) {
 		if (c[i]>='0' && c[i]<='9') d=c[i]-'0'; else
 		if (c[i]>='a' && c[i]<='f') d=c[i]-'a'+10; else
 		if (c[i]>='A' && c[i]<='F') d=c[i]-'A'+10; else
 		return -1;
-		r = r<<4 +d;
+		r = (r<<4) + d;
 	}
+	return r;
 }
 
-
 /* Returns 0 - nothing found
   *              1  - T found
   */
@@ -613,6 +613,7 @@ int t_reply_matching( struct s_table *hash_table , struct sip_msg *p_msg , struc
    hashi=p;
    p=n+1;scan_space--;
 
+
    /* sequence id */
    n=eat_token2_end( p, p+scan_space, '.');
    synl=n-p;
@@ -627,12 +628,20 @@ int t_reply_matching( struct s_table *hash_table , struct sip_msg *p_msg , struc
    if (!branchl ) goto nomatch; 
    branchi=p;
 
-   if ((hash_index=str_unsigned_hex_2_int(hashi, hashl))==0 ||
-        hash_index>=TABLE_ENTRIES ||
-       (entry_label=str_unsigned_hex_2_int(syni, synl))==0 ||
-       (branch_id=str_unsigned_hex_2_int(branchi, branchl))==0 ||
+
+   hash_index=str_unsigned_hex_2_int(hashi, hashl);
+   entry_label=str_unsigned_hex_2_int(syni, synl);
+   branch_id=str_unsigned_hex_2_int(branchi, branchl);
+
+   DBG("DEBUG: t_reply_matching: hash %d label %d branch %d\n", 
+	hash_index, entry_label, branch_id );
+
+   /* sanity check */
+   if (hash_index==-1 || hash_index >=TABLE_ENTRIES ||
+       entry_label==-1 || branch_id==-1 ||
 	branch_id>=MAX_FORK )
-	goto nomatch;
+		goto nomatch;
+
 
    /*all the cells from the entry are scan to detect an entry_label matching */
    p_cell     = hash_table->entrys[hash_index].first_cell;
@@ -660,7 +669,10 @@ int t_reply_matching( struct s_table *hash_table , struct sip_msg *p_msg , struc
    } /* while p_cell */
 
    /* nothing found */
+   DBG("DEBUG: t_reply_matching: no matching transaction exists\n");
+
 nomatch:
+   DBG("DEBUG: t_reply_matching: failure to match a transaction\n");
    *p_branch = -1;
    *p_Trans = NULL;
    return 0;

+ 20 - 20
parser_f.h

@@ -18,35 +18,35 @@ int is_empty(char* buffer, unsigned int len);
 
 
 #define eat_space_end(buffer,pend)                                       \
-  ( {   char *p;                                                 	\
-	char *pe=(pend);						\
-        for(p=(buffer);(p<pe)&& (*p==' ' || *p=='\t') ;p++);		\
-        p;                                                              \
+  ( {   char *_p;                                                 	\
+	char *_pe=(pend);						\
+        for(_p=(buffer);(_p<_pe)&& (*_p==' ' || *_p=='\t') ;_p++);		\
+        _p;                                                              \
   } )
 
 #define eat_token_end(buffer,pend)					\
-  ( { char *p       ;							\
-      char *pe=(pend);						\
-      for (p=(buffer);(p<pe)&&					\
-                        (*p!=' ')&&(*p!='\t')&&(*p!='\n')&&(*p!='\r');	\
-                p++);							\
-      p;								\
+  ( { char *_p       ;							\
+      char *_pe=(pend);						\
+      for (_p=(buffer);(_p<_pe)&&					\
+                        (*_p!=' ')&&(*_p!='\t')&&(*_p!='\n')&&(*_p!='\r');	\
+                _p++);							\
+      _p;								\
   } )
 
 #define eat_token2_end(buffer,pend,delim)					\
-  ( { char *p       ;							\
-      char *pe=(pend);						\
-      for (p=(buffer);(p<pe)&&					\
-                        (*p!=(delim))&&(*p!='\n')&&(*p!='\r');		\
-                p++);							\
-      p;								\
+  ( { char *_p       ;							\
+      char *_pe=(pend);						\
+      for (_p=(buffer);(_p<_pe)&&					\
+                        (*_p!=(delim))&&(*_p!='\n')&&(*_p!='\r');		\
+                _p++);							\
+      _p;								\
   } )
 
 #define is_empty_end(buffer, pend )					\
-  ( { char *p;								\
-      char *pe=(pend);						\
-      p=eat_space_end( buffer, pe );					\
-      ((p<pend ) && (*p=='\r' || *p=='\n')) ? 1 : 0;			\
+  ( { char *_p;								\
+      char *_pe=(pend);						\
+      _p=eat_space_end( buffer, _pe );					\
+      ((_p<(pend )) && (*_p=='\r' || *_p=='\n')) ? 1 : 0;			\
   } )