소스 검색

*** empty log message ***

Bogdan-Andrei Iancu 23 년 전
부모
커밋
6beabeca20
14개의 변경된 파일196개의 추가작업 그리고 185개의 파일을 삭제
  1. 1 2
      Makefile.defs
  2. 6 0
      mem/shm_mem.h
  3. 43 46
      modules/tm/h_table.c
  4. 6 6
      modules/tm/hash_func.c
  5. 2 0
      modules/tm/lock.h
  6. 3 0
      modules/tm/sip_msg.c
  7. 4 84
      modules/tm/t_funcs.c
  8. 79 2
      modules/tm/t_funcs.h
  9. 14 11
      modules/tm/t_fwd.c
  10. 9 10
      modules/tm/t_lookup.c
  11. 5 7
      modules/tm/t_reply.c
  12. 2 1
      modules/tm/timer.c
  13. 1 1
      modules/tm/timer.h
  14. 21 15
      modules/tm/tm.c

+ 1 - 2
Makefile.defs

@@ -79,9 +79,8 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 -DDNS_IP_HACK  -DPKG_MALLOC \
 	 -DF_MALLOC  -DUSE_SYNONIM\
 	 -DSHM_MEM  -DSHM_MMAP \
-	 -DNO_DEBUG \
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
-	 -DWAIT -DNEW_HNAME # -DNOISY_REPLIES -DBOGDAN_TRIFLE \
+	 -DWAIT -DNEW_HNAME  -DNOISY_REPLIES -DBOGDAN_TRIFLE \
 	 #-DNO_DEBUG \
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
 	 #-DNOSMP \

+ 6 - 0
mem/shm_mem.h

@@ -172,6 +172,12 @@ inline static void* shm_malloc(unsigned int size)
 }
 
 
+#ifdef DBG_QM_MALLOC
+void* _shm_resize( void*, unsigned int, char*, char*, unsigned int);
+#else
+void* _shm_resize( void*, unsigned int);
+#endif
+
 
 #define shm_free_unsafe( _p ) MY_FREE(shm_block, (_p))
 

+ 43 - 46
modules/tm/h_table.c

@@ -8,8 +8,7 @@
 #include "sh_malloc.h"
 #include "../../md5utils.h"
 
-/*   Frees the all the containes of a cell and the cell's body itself
-  */
+/* containes of a cell and the cell's body itself */
 void free_cell( struct cell* dead_cell )
 {
 	int i;
@@ -21,24 +20,24 @@ void free_cell( struct cell* dead_cell )
 	shm_lock();
 	if ( dead_cell->inbound_request )
 		sip_msg_free_unsafe( dead_cell->inbound_request );
-	if (b=dead_cell->outbound_response.retr_buffer)
+	if ((b=dead_cell->outbound_response.retr_buffer))
 		shm_free_unsafe( b );
 
 	/* UA Clients */
 	for ( i =0 ; i<dead_cell->nr_of_outgoings;  i++ )
 	{
 		/* outbound requests*/
-		if ( rb=dead_cell->outbound_request[i] )
+		if ( (rb=dead_cell->outbound_request[i]) )
 		{
 			if (rb->retr_buffer) shm_free_unsafe( rb->retr_buffer );
 			dead_cell->outbound_request[i] = NULL;
 			shm_free_unsafe( rb );
 		}
 		/* outbound ACKs, if any */
-		if (rb=dead_cell->outbound_ack[i] )
+		if ( (rb=dead_cell->outbound_ack[i]) )
 			shm_free_unsafe( rb );
 		/* local cancel , if any */
-		if (rb=dead_cell->outbound_cancel[i] )
+		if ( (rb=dead_cell->outbound_cancel[i]) )
 			shm_free_unsafe( rb );
 		/* inbound response */
 		if ( dead_cell -> inbound_response[i] )
@@ -93,7 +92,6 @@ void free_hash_table( struct s_table *hash_table )
 struct s_table* init_hash_table()
 {
    struct s_table*  hash_table;
-   pthread_t  thread;
    int       i;
 
    /*allocs the table*/
@@ -130,55 +128,54 @@ error:
 
 struct cell*  build_cell( struct sip_msg* p_msg )
 {
-   struct cell*  new_cell;
-   str                src[5];
-   int                i;
+	struct cell* new_cell;
+#ifndef USE_SYNONIM
+	str          src[5];
+#endif
 
-    /* do we have the source for the build process? */
-   if (!p_msg)
-      return NULL;
+	/* do we have the source for the build process? */
+	if (!p_msg)
+		return NULL;
 
-   /* allocs a new cell */
-   new_cell = (struct cell*)sh_malloc( sizeof( struct cell ) );
-   if  ( !new_cell )
-      return NULL;
+	/* allocs a new cell */
+	new_cell = (struct cell*)sh_malloc( sizeof( struct cell ) );
+	if  ( !new_cell )
+		return NULL;
 
-   /* filling with 0 */
-   memset( new_cell, 0, sizeof( struct cell ) );
+	/* filling with 0 */
+	memset( new_cell, 0, sizeof( struct cell ) );
 
-   new_cell->outbound_response.retr_timer.tg=TG_RT;
-   new_cell->outbound_response.fr_timer.tg=TG_FR;
-   new_cell->wait_tl.tg=TG_WT;
-   new_cell->dele_tl.tg=TG_DEL;
+	new_cell->outbound_response.retr_timer.tg=TG_RT;
+	new_cell->outbound_response.fr_timer.tg=TG_FR;
+	new_cell->wait_tl.tg=TG_WT;
+	new_cell->dele_tl.tg=TG_DEL;
 
-   /* hash index of the entry */
-   /* new_cell->hash_index = hash( p_msg->callid->body , get_cseq(p_msg)->number ); */
+	/* hash index of the entry */
 	new_cell->hash_index = p_msg->hash_index;
-   /* mutex */
-   /* ref counter is 0 */
-   /* all pointers from timers list tl are NULL */
-   new_cell->wait_tl.payload = new_cell;
-   new_cell->dele_tl.payload = new_cell;
-
-   new_cell->inbound_request =  sip_msg_cloner(p_msg) ;
-   if (!new_cell->inbound_request)
-	goto error;
-   new_cell->relaied_reply_branch   = -1;
-   new_cell->T_canceled = T_UNDEFINED;
-   new_cell->tag=&(get_to(new_cell->inbound_request)->tag_value);
+	/* mutex */
+	/* ref counter is 0 */
+	/* all pointers from timers list tl are NULL */
+	new_cell->wait_tl.payload = new_cell;
+	new_cell->dele_tl.payload = new_cell;
+
+	new_cell->inbound_request =  sip_msg_cloner(p_msg) ;
+	if (!new_cell->inbound_request)
+		goto error;
+	new_cell->relaied_reply_branch   = -1;
+	new_cell->T_canceled = T_UNDEFINED;
+	new_cell->tag=&(get_to(new_cell->inbound_request)->tag_value);
 #ifndef USE_SYNONIM
-   src[0]= p_msg->from->body;
-   src[1]= p_msg->to->body;
-   src[2]= p_msg->callid->body;
-   src[3]= p_msg->first_line.u.request.uri;
-   src[4]= get_cseq( p_msg )->number;
-   MDStringArray ( new_cell->md5, src, 5 );
-
+	src[0]= p_msg->from->body;
+	src[1]= p_msg->to->body;
+	src[2]= p_msg->callid->body;
+	src[3]= p_msg->first_line.u.request.uri;
+	src[4]= get_cseq( p_msg )->number;
+	MDStringArray ( new_cell->md5, src, 5 );
 #endif
 
-    init_cell_lock(  new_cell );
+	init_cell_lock(  new_cell );
 
-   return new_cell;
+	return new_cell;
 
 error:
 	sh_free(new_cell);

+ 6 - 6
modules/tm/hash_func.c

@@ -75,7 +75,6 @@ int new_hash( str call_id, str cseq_nr )
 	int hash_code = 0;
 	int i,j, k, third;
 	int ci_len, cs_len;
-	char c;
 	char *ci, *cs;
 
 	/* trim EoLs */
@@ -96,8 +95,8 @@ int new_hash( str call_id, str cseq_nr )
 	third=(ci_len-1)/3;
 	for ( i=ci_len-1, j=2*third, k=third;
 		k>0 ; i--, j--, k-- ) {
-		hash_code+=crc_16_tab[*(ci+i) /*+7*/ ]+
-			ccitt_tab[*(ci+k)+63]+	
+		hash_code+=crc_16_tab[(unsigned char)(*(ci+i)) /*+7*/ ]+
+			ccitt_tab[*(ci+k)+63]+
 			ccitt_tab[*(ci+j)+13];
 	}
 	for( i=0 ; i<cs_len ; i++ )
@@ -111,7 +110,7 @@ int new_hash( str call_id, str cseq_nr )
 void hashtest_cycle( int hits[TABLE_ENTRIES], char *ip )
 {
 	long int i,j,k, l;
-	int len1, len2, hashv;
+	int  hashv;
 	static char buf1[1024];
 	static char buf2[1024];
 	str call_id; 
@@ -124,8 +123,9 @@ void hashtest_cycle( int hits[TABLE_ENTRIES], char *ip )
 		for (j=85296341;j<85296341+10;j++)
 			for (k=987654;k<=987654+10;k++)
 				for (l=101;l<201;l++) {
-					call_id.len=sprintf( buf1, "%d-%d-%d@%s", i,j,k, ip );
-					cseq.len=sprintf( buf2, "%d", l );
+					call_id.len=sprintf( buf1, "%d-%d-%d@%s",(int)i,(int)j,
+						(int)k, ip );
+					cseq.len=sprintf( buf2, "%d", (int)l );
 					printf("%s\t%s\n", buf1, buf2 );
 					hashv=hash( call_id, cseq );
 					hits[ hashv ]++;

+ 2 - 0
modules/tm/lock.h

@@ -75,6 +75,8 @@ static int change_semaphore( ser_lock_t s  , int val );
 
 int init_cell_lock( struct cell *cell );
 int init_entry_lock( struct s_table* hash_table, struct entry *entry );
+int init_timerlist_lock( struct s_table* hash_table, enum lists timerlist_id);
+
 
 int release_cell_lock( struct cell *cell );
 int release_entry_lock( struct entry *entry );

+ 3 - 0
modules/tm/sip_msg.c

@@ -415,3 +415,6 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
 }
 
 
+
+
+

+ 4 - 84
modules/tm/t_funcs.c

@@ -9,7 +9,7 @@
 #include "../../config.h"
 #include "../../parser_f.h"
 #include "../../ut.h"
-#include "../../timer.h"
+//#include "../../timer.h"
 
 
 
@@ -32,83 +32,6 @@ void timer_routine(unsigned int, void*);
 
 
 
-
-
-/* remove from timer list */
-inline void reset_timer( struct s_table *hash_table, struct timer_link* tl )
-{
-	/* lock(timer_group_lock[ tl->tg ]); */
-	/* hack to work arround this timer group thing*/
-	lock(hash_table->timers[timer_group[tl->tg]].mutex);
-	remove_timer_unsafe( tl );
-	unlock(hash_table->timers[timer_group[tl->tg]].mutex);
-	/*unlock(timer_group_lock[ tl->tg ]);*/
-}
-
-
-
-
-/* determine timer length and put on a correct timer list */
-inline void set_timer( struct s_table *hash_table, struct timer_link *new_tl,
-														enum lists list_id )
-{
-	unsigned int timeout;
-	struct timer* list;
-	static enum lists to_table[NR_OF_TIMER_LISTS] = {
-		FR_TIME_OUT, INV_FR_TIME_OUT, WT_TIME_OUT, DEL_TIME_OUT,
-		RETR_T1, RETR_T1 << 1, RETR_T1 << 2, RETR_T2 };
-
-	if (list_id<FR_TIMER_LIST || list_id>=NR_OF_TIMER_LISTS) {
-		LOG(L_CRIT, "ERROR: set_timer: unkown list: %d\n", list_id);
-#ifdef EXTRA_DEBUG
-		abort();
-#endif
-		return;
-	}
-	timeout = to_table[ list_id ];
-	list= &(hash_table->timers[ list_id ]);
-
-	lock(list->mutex);
-	/* make sure I'm not already on a list */
-	remove_timer_unsafe( new_tl );
-	add_timer_unsafe( list, new_tl, get_ticks()+timeout);
-	unlock(list->mutex);
-}
-
-
-
-
-static inline void reset_retr_timers( struct s_table *h_table,
-													struct cell *p_cell )
-{
-	int ijk;
-	struct retrans_buff *rb;
-
-	/* lock the first timer list of the FR group -- all other
-	   lists share the same lock*/
-	lock(hash_table->timers[RT_T1_TO_1].mutex);
-	remove_timer_unsafe( & p_cell->outbound_response.retr_timer );
-	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
-		if ( rb = p_cell->outbound_request[ijk] ) {
-			remove_timer_unsafe( & rb->retr_timer );
-		}
-	}
-	unlock(hash_table->timers[RT_T1_TO_1].mutex);
-
-	lock(hash_table->timers[FR_TIMER_LIST].mutex);
-	remove_timer_unsafe( & p_cell->outbound_response.fr_timer );
-	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
-		if ( rb = p_cell->outbound_request[ijk] ) {
-			remove_timer_unsafe( & rb->fr_timer );
-		}
-	}
-	unlock(hash_table->timers[FR_TIMER_LIST].mutex);
-	DBG("DEBUG:stop_RETR_and_FR_timers : timers stopped\n");
-}
-
-
-
-
 int tm_startup()
 {
 	/* building the hash table*/
@@ -344,9 +267,8 @@ int t_should_relay_response( struct cell *Trans , int new_code,
   */
 int t_put_on_wait(  struct cell  *Trans  )
 {
-	struct timer_link *tl;
 	unsigned int i;
-	struct retrans_buff* rb;
+	//struct retrans_buff* rb;
 
 #ifndef WAIT
 	if (is_in_timer_list2( &(Trans->wait_tl)))
@@ -414,6 +336,7 @@ int t_put_on_wait(  struct cell  *Trans  )
 int t_cancel_branch(unsigned int branch)
 {
 	LOG(L_ERR, "ERROR: t_cancel_branch: NOT IMPLEMENTED YET\n");
+	return 1;
 }
 
 
@@ -565,7 +488,6 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
 	struct hdr_field    *hdr;
 	char                *cancel_buf, *p, *via;
 	unsigned int         len, via_len;
-	int                  n;
 	struct retrans_buff *srb;
 
 	if (Trans->outbound_cancel[branch]!=NO_CANCEL)
@@ -846,7 +768,7 @@ inline void retransmission_handler( void *attr)
 {
 	struct retrans_buff* r_buf ;
 	enum lists id;
-	DBG("DEBUG: entering retransmisson with attr = %x\n",attr);
+	DBG("DEBUG: entering retransmisson with attr = %p\n",attr);
 	r_buf = (struct retrans_buff*)attr;
 #ifdef EXTRA_DEBUG
 	if (r_buf->my_T->damocles) {
@@ -991,7 +913,6 @@ inline void delete_handler( void *attr)
 void timer_routine(unsigned int ticks , void * attr)
 {
 	struct s_table    *hash_table = (struct s_table *)attr;
-	struct timer*      timers= hash_table->timers;
 	struct timer_link *tl, *tmp_tl;
 	int                id;
 
@@ -1043,7 +964,6 @@ struct retrans_buff *build_ack( struct sip_msg* rpl, struct cell *trans, int bra
 	struct hdr_field    *hdr;
 	char                *ack_buf, *p, *via;
 	unsigned int         len, via_len;
-	int                  n;
 	struct retrans_buff *srb;
 
 	ack_buf = 0;

+ 79 - 2
modules/tm/t_funcs.h

@@ -13,6 +13,7 @@
 #include "../../globals.h"
 #include "../../udp_server.h"
 #include "../../msg_translator.h"
+#include "../../timer.h"
 #include "../../forward.h"
 #include "../../mem/mem.h"
 
@@ -259,8 +260,6 @@ int t_should_relay_response( struct cell *Trans, int new_code, int branch,
 int t_update_timers_after_sending_reply( struct retrans_buff *rb );
 int t_put_on_wait(  struct cell  *Trans  );
 int relay_lowest_reply_upstream( struct cell *Trans , struct sip_msg *p_msg );
-static int push_reply( struct cell* trans , unsigned int branch ,
-	char *buf, unsigned int len);
 int add_branch_label( struct cell *Trans, struct sip_msg *p_msg , int branch );
 int get_ip_and_port_from_uri( struct sip_msg* p_msg , unsigned int *param_ip,
 	unsigned int *param_port);
@@ -304,4 +303,82 @@ inline int static relay_ack( struct cell *t, int branch,
 }
 
 
+
+
+/* remove from timer list */
+static inline void reset_timer( struct s_table *hash_table,
+													struct timer_link* tl )
+{
+	/* lock(timer_group_lock[ tl->tg ]); */
+	/* hack to work arround this timer group thing*/
+	lock(hash_table->timers[timer_group[tl->tg]].mutex);
+	remove_timer_unsafe( tl );
+	unlock(hash_table->timers[timer_group[tl->tg]].mutex);
+	/*unlock(timer_group_lock[ tl->tg ]);*/
+}
+
+
+
+
+/* determine timer length and put on a correct timer list */
+static inline void set_timer( struct s_table *hash_table,
+							struct timer_link *new_tl, enum lists list_id )
+{
+	unsigned int timeout;
+	struct timer* list;
+	static enum lists to_table[NR_OF_TIMER_LISTS] = {
+		FR_TIME_OUT, INV_FR_TIME_OUT, WT_TIME_OUT, DEL_TIME_OUT,
+		RETR_T1, RETR_T1 << 1, RETR_T1 << 2, RETR_T2 };
+
+	if (list_id<FR_TIMER_LIST || list_id>=NR_OF_TIMER_LISTS) {
+		LOG(L_CRIT, "ERROR: set_timer: unkown list: %d\n", list_id);
+#ifdef EXTRA_DEBUG
+		abort();
 #endif
+		return;
+	}
+	timeout = to_table[ list_id ];
+	list= &(hash_table->timers[ list_id ]);
+
+	lock(list->mutex);
+	/* make sure I'm not already on a list */
+	remove_timer_unsafe( new_tl );
+	add_timer_unsafe( list, new_tl, get_ticks()+timeout);
+	unlock(list->mutex);
+}
+
+
+
+
+static inline void reset_retr_timers( struct s_table *h_table,
+													struct cell *p_cell )
+{
+	int ijk;
+	struct retrans_buff *rb;
+
+	/* lock the first timer list of the FR group -- all other
+	   lists share the same lock*/
+	lock(hash_table->timers[RT_T1_TO_1].mutex);
+	remove_timer_unsafe( & p_cell->outbound_response.retr_timer );
+	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
+		if ( (rb = p_cell->outbound_request[ijk]) ) {
+			remove_timer_unsafe( & rb->retr_timer );
+		}
+	}
+	unlock(hash_table->timers[RT_T1_TO_1].mutex);
+
+	lock(hash_table->timers[FR_TIMER_LIST].mutex);
+	remove_timer_unsafe( & p_cell->outbound_response.fr_timer );
+	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
+		if ( (rb = p_cell->outbound_request[ijk]) ) {
+			remove_timer_unsafe( & rb->fr_timer );
+		}
+	}
+	unlock(hash_table->timers[FR_TIMER_LIST].mutex);
+	DBG("DEBUG:stop_RETR_and_FR_timers : timers stopped\n");
+}
+
+
+
+#endif
+

+ 14 - 11
modules/tm/t_fwd.c

@@ -18,13 +18,13 @@
 int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
 	unsigned int dest_port_param )
 {
-	unsigned int dest_ip     = dest_ip_param;
-	unsigned int dest_port  = dest_port_param;
-	int	branch;
-	unsigned int len;
-	char               *buf, *shbuf;
-	struct retrans_buff *rb;
-	struct cell      *T_source = T;
+	unsigned int        dest_ip = dest_ip_param;
+	unsigned int        dest_port = dest_port_param;
+	int                  branch;
+	unsigned int         len;
+	char                *buf, *shbuf;
+	struct retrans_buff *rb = 0;
+	struct cell         *T_source = T;
 
 
 	buf=NULL;
@@ -161,15 +161,16 @@ error:
 }
 
 int t_forward_ack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
-	unsigned int dest_port_param )
+										unsigned int dest_port_param )
 {
-
 	int branch;
 	int len;
 	char *buf;
-	struct sockaddr_in to_sock;
-	struct retrans_buff *rb;
 	struct retrans_buff *srb;
+#ifdef _DONT_USE
+	struct sockaddr_in to_sock;
+#endif
+
 
 
 	/* drop local ACKs */
@@ -227,6 +228,7 @@ int t_forward_ack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
 	relay_ack( T, branch, srb, len );
 	return 1;
 
+#ifdef _DON_USE
 fwd_sl: /* some strange conditions occured; try statelessly */
 	LOG(L_ERR, "ERROR: fwd-ing a 2xx ACK with T-state failed; "
 		"trying statelessly\n");
@@ -238,4 +240,5 @@ fwd_sl: /* some strange conditions occured; try statelessly */
 		sizeof(struct sockaddr_in) );
 	free( buf );
 	return 1;
+#endif
 }

+ 9 - 10
modules/tm/t_lookup.c

@@ -221,7 +221,7 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table ,
 					&& EQ_STR(from) )
 					{ /* WE FOUND THE GOLDEN EGG !!!! */
 						DBG("DEBUG: t_lookupOriginalT: canceled transaction"
-							" found (%x)! \n",p_cell );
+							" found (%p)! \n",p_cell );
 						return p_cell;
 					}
 		/* next transaction */
@@ -244,13 +244,16 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
 												unsigned int *local_cancel)
 {
 	struct cell*  p_cell;
-	unsigned int loop_code    = 0;
 	unsigned int hash_index   = 0;
 	unsigned int entry_label  = 0;
 	unsigned int branch_id    = 0;
-	char  *loopi,*hashi, *syni, *branchi, *p, *n;
-	int loopl,hashl, synl, branchl;
+	char  *hashi, *syni, *branchi, *p, *n;
+	int hashl, synl, branchl;
 	int scan_space;
+#ifndef USE_SYNONIM
+	char *loopi;
+	int loopl;
+#endif
 
 	/* split the branch into pieces: loop_detection_check(ignored),
 	 hash_table_id, synonym_id, branch_id */
@@ -356,8 +359,6 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
 	/* nothing found */
 	DBG("DEBUG: t_reply_matching: no matching transaction exists\n");
 
-nomatch:
-	unlock(&(hash_table->entrys[hash_index].mutex));
 nomatch2:
 	DBG("DEBUG: t_reply_matching: failure to match a transaction\n");
 	*p_branch = -1;
@@ -425,10 +426,8 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
 */
 int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
 {
-	char *c;
-
 	char *begin;
-	unsigned int size, orig_size, n;
+	unsigned int size, orig_size;
 
 	begin=p_msg->add_to_branch_s+p_msg->add_to_branch_len;
 	orig_size = size=MAX_BRANCH_PARAM_LEN - p_msg->add_to_branch_len;
@@ -446,7 +445,7 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
 	if (int2reverse_hex( &begin, &size, branch)==-1) return -1;
 
 	p_msg->add_to_branch_len+=(orig_size-size);
-	DBG("DEBUG: XXX branch label created now: %.*s (%d)\n",
+	DBG("DEBUG: XXX branch label created now: %.*s\n",
 		p_msg->add_to_branch_len, p_msg->add_to_branch_s );
 	return 0;
 

+ 5 - 7
modules/tm/t_reply.c

@@ -51,7 +51,7 @@ int t_retransmit_reply( /* struct sip_msg* p_msg    */ )
 int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
 {
 	unsigned int len, buf_len;
-	char * buf, *shbuf;
+	char * buf;
 	struct retrans_buff *rb;
 
 	buf = build_res_buf_from_sip_req(code,text,T->tag->s,T->tag->len,
@@ -192,15 +192,15 @@ error:
   */
 int t_on_reply( struct sip_msg  *p_msg )
 {
-	unsigned int branch,len, msg_status, msg_class, save_clone;
+	unsigned int branch, msg_status, msg_class, save_clone;
 	unsigned int local_cancel;
-	struct sip_msg *clone, *backup;
+	struct sip_msg *clone=0, *backup=0;
 	int relay;
 	int start_fr = 0;
 	int is_invite;
 	/* retransmission structure of outbound reply and request */
-	struct retrans_buff *orq_rb, *orp_rb, *ack_rb;
-	char *buf;
+	struct retrans_buff *orq_rb=0, *orp_rb=0, *ack_rb=0;
+	char *buf=0;
 	/* length of outbound reply */
 	unsigned int orp_len;
 	/* buffer length (might be somewhat larger than message size */
@@ -342,8 +342,6 @@ int t_on_reply( struct sip_msg  *p_msg )
 		T->tag=&(get_to(clone)->tag_value);
 	}
 
-
-cleanup:
 	UNLOCK_REPLIES( T );
 	if (relay >= 0) {
 		SEND_PR_BUFFER( orp_rb, buf, orp_len );

+ 2 - 1
modules/tm/timer.c

@@ -7,6 +7,7 @@
 #include "h_table.h"
 #include "timer.h"
 #include "../../dprint.h"
+#include "lock.h"
 
 int timer_group[NR_OF_TIMER_LISTS] = 
 {
@@ -117,7 +118,7 @@ void add_timer_unsafe( struct timer *timer_list, struct timer_link *tl,
 struct timer_link  *check_and_split_time_list( struct timer *timer_list,
 																int time )
 {
-	struct timer_link *tl , *tmp , *end, *ret;
+	struct timer_link *tl , *end, *ret;
 
 	/* quick check whether it is worth entering the lock */
 	if (timer_list->first_tl.next_tl==&timer_list->last_tl ||

+ 1 - 1
modules/tm/timer.h

@@ -5,7 +5,6 @@
 #ifndef _TIMER_H
 #define _TIMER_H
 
-#include "lock.h"
 
 
 
@@ -29,6 +28,7 @@ enum lists
 extern int timer_group[NR_OF_TIMER_LISTS];
 struct timer;
 
+#include "lock.h"
 
 
 /* all you need to put a cell in a timer list

+ 21 - 15
modules/tm/tm.c

@@ -25,10 +25,10 @@ static int w_t_check(struct sip_msg* msg, char* str, char* str2);
 static int w_t_send_reply(struct sip_msg* msg, char* str, char* str2);
 static int w_t_release(struct sip_msg* msg, char* str, char* str2);
 static int fixup_t_forward(void** param, int param_no);
-static int fixup_t_forward_def(void** param, int param_no);
+//static int fixup_t_forward_def(void** param, int param_no);
 static int fixup_t_send_reply(void** param, int param_no);
 static int w_t_unref( struct sip_msg* p_msg, char* foo, char* bar );
-static w_t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar  );
+static int w_t_retransmit_reply(struct sip_msg* p_msg, char* foo, char* bar );
 static int w_t_add_transaction( struct sip_msg* p_msg, char* foo, char* bar );
 
 static int t_relay_to( struct sip_msg  *p_msg ,  char *str_ip , char *str_port  );
@@ -151,7 +151,7 @@ static int fixup_t_forward(void** param, int param_no)
 			return 0;
 		}else{
 			LOG(L_ERR, "TM module:fixup_t_forward: bad port number <%s>\n",
-					*param);
+					(char*)(*param));
 			return E_UNSPEC;
 		}
 	}
@@ -159,7 +159,7 @@ static int fixup_t_forward(void** param, int param_no)
 }
 
 
-
+/*
 static int fixup_t_forward_def(void** param, int param_no)
 {
 	char* name;
@@ -180,7 +180,7 @@ static int fixup_t_forward_def(void** param, int param_no)
 			goto copy;
 		}
 #endif
-		/* fail over to normal lookup */
+		/ fail over to normal lookup /
 		he=gethostbyname(name);
 		if (he==0){
 			LOG(L_CRIT, "ERROR: mk_proxy: could not resolve hostname:"
@@ -195,7 +195,7 @@ static int fixup_t_forward_def(void** param, int param_no)
 	}
 	return 0;
 }
-
+*/
 
 
 static int fixup_t_send_reply(void** param, int param_no)
@@ -211,7 +211,7 @@ static int fixup_t_send_reply(void** param, int param_no)
 			return 0;
 		}else{
 			LOG(L_ERR, "TM module:fixup_t_send_reply: bad  number <%s>\n",
-					*param);
+					(char*)(*param));
 			return E_UNSPEC;
 		}
 	}
@@ -274,11 +274,15 @@ static int w_t_unref( struct sip_msg* p_msg, char* foo, char* bar )
     return t_unref( /* p_msg */ );
 }
 
-static w_t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar  )
+static int w_t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar)
 {
-	if (t_check( p_msg  , 0 , 0 )==-1) return 1;
-	if (T) return t_retransmit_reply( p_msg );
-	else return -1;
+	if (t_check( p_msg  , 0 , 0 )==-1) 
+		return 1;
+	if (T)
+		return t_retransmit_reply( p_msg );
+	else 
+		return -1;
+	return 1;
 }
 
 static int w_t_add_transaction( struct sip_msg* p_msg, char* foo, char* bar ) {
@@ -294,9 +298,9 @@ static int w_t_add_transaction( struct sip_msg* p_msg, char* foo, char* bar ) {
 
 static int t_relay_to( struct sip_msg  *p_msg , char *str_ip , char *str_port)
 {
-
+	struct proxy_l *proxy;
 	enum addifnew_status status;
-	int ret;
+	int ret=0;
 
 	status = t_addifnew( p_msg );
 
@@ -332,8 +336,10 @@ static int t_relay_to( struct sip_msg  *p_msg , char *str_ip , char *str_port)
 			break;
 		case AIN_NEWACK:	/* it's an ACK for which no transaction exists */
 			DBG( "SER: forwarding ACK  statelessly\n");
-			forward_request( p_msg , mk_proxy_from_ip(
-				(unsigned int )str_ip, (unsigned int)str_port) ) ;
+			proxy=mk_proxy_from_ip((unsigned int)str_ip,(unsigned int)str_port);
+			forward_request( p_msg , proxy ) ;
+			free_proxy(proxy);
+			free(proxy);
 			ret=1;
 			break;
 		case AIN_OLDACK:	/* it's an ACK for an existing transaction */