Bogdan-Andrei Iancu 23 лет назад
Родитель
Сommit
b25c055df9
7 измененных файлов с 37 добавлено и 26 удалено
  1. 1 1
      Makefile
  2. 7 2
      Makefile.defs
  3. 11 8
      modules/tm/t_funcs.c
  4. 11 6
      modules/tm/t_funcs.h
  5. 5 7
      modules/tm/t_reply.c
  6. 1 1
      modules/tm/tm.c
  7. 1 1
      test/th-uri.cfg

+ 1 - 1
Makefile

@@ -10,7 +10,7 @@ auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
 #include  source related defs
 include Makefile.sources
 
-exclude_modules=CVS mysql auth rr usrloc
+exclude_modules=CVS mysql auth rr
 static_modules=
 static_modules_path=$(addprefix modules/, $(static_modules))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))

+ 7 - 2
Makefile.defs

@@ -72,7 +72,11 @@ ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
 #		protection against race condiditions; turn off only for debugging;
 #       to become non-optional if stable
 # -DNEW_HNAME
-#		32-bit header name parsing; turn off for lower speed ;-) or debugging; to become non-optional if fast and stable
+#		32-bit header name parsing; turn off for lower speed ;-) or debugging;
+#		to become non-optional if fast and stable
+# -SILENT_FR
+#		if defined, when FR timer hits (in tm) cancel is sent only if forking
+#		if used; otherwise, just delete the transaction without doing anything
 
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
@@ -80,8 +84,9 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 -DF_MALLOC  -DUSE_SYNONIM\
 	 -DSHM_MEM  -DSHM_MMAP \
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
+	 -DWAIT -DNEW_HNAME\ #-DNOISY_REPLIES -DBOGDAN_TRIFLE \
+	 -DSILENT_FR \
 	 -DNO_DEBUG \
-	 -DWAIT -DNEW_HNAME   # -DNOISY_REPLIES -DBOGDAN_TRIFLE \
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
 	 #-DNOSMP \
 	 #-DEXTRA_DEBUG 

+ 11 - 8
modules/tm/t_funcs.c

@@ -13,7 +13,6 @@
 
 
 
-
 #define  append_mem_block(_d,_s,_len) \
 		do{\
 			memcpy((_d),(_s),(_len));\
@@ -282,19 +281,18 @@ int t_put_on_wait(  struct cell  *Trans  )
 	  if so, exit now
 	*/
 
-	LOCK_WAIT(T);
+	LOCK_WAIT(Trans);
 	if (Trans->on_wait)
 	{
 		DBG("DEBUG: t_put_on_wait: already on wait\n");
-		UNLOCK_WAIT(T);
+		UNLOCK_WAIT(Trans);
 		return 1;
 	} else {
 		Trans->on_wait=1;
-		UNLOCK_WAIT(T);
-	};
+		UNLOCK_WAIT(Trans);
+	}
 #endif
 
-
 	/* remove from  retranssmision  and  final response   list */
 	DBG("DEBUG: t_put_on_wait: stopping timers (FR and RETR)\n");
 	reset_retr_timers(hash_table,Trans) ;
@@ -829,7 +827,12 @@ inline void final_response_handler( void *attr)
 		return;
 	}
 	/* send a 408 */
-	if ( r_buf->my_T->status<200)
+	if ( r_buf->my_T->status<200
+#ifdef SILENT_FR
+	&& printf("shit ma' man!!!\n") && (0)
+	/*should be fork==yes, but we don't have forking yet - bogdan */
+#endif
+	)
 	{
 		DBG("DEBUG: FR_handler:stop retr. and send CANCEL (%p)\n",r_buf->my_T);
 		reset_timer( hash_table, &(r_buf->retr_timer) );
@@ -845,7 +848,7 @@ inline void final_response_handler( void *attr)
 		t_send_reply( r_buf->my_T->inbound_request,408,"Request Timeout" );
 	}else{
 		/* put it on WT_LIST - transaction is over */
-		DBG("DEBUG: final_response_handler:cancel transaction->put on wait"
+		DBG("DEBUG: final_response_handler:-> put on wait"
 			" (t=%p)\n", r_buf->my_T);
 		t_put_on_wait(  r_buf->my_T );
 	}

+ 11 - 6
modules/tm/t_funcs.h

@@ -52,12 +52,17 @@ extern struct s_table*  hash_table;
    for reducing time spend in REPLIES locks
 */
 
-#define SEND_PR_BUFFER(_rb,_bf,_le ) ({ if ((_rb)->retr_buffer) \
-	{ udp_send( (_bf), (_le), (struct sockaddr*)&((_rb)->to) , \
-	   sizeof(struct sockaddr_in) ); \
-	} else { \
-	DBG("ERROR: attempt to send an empty buffer from %s (%d)", \
-	__FUNCTION__, __LINE__ ); }})
+#define SEND_PR_BUFFER(_rb,_bf,_le ) \
+	{\
+		if ((_rb) && (_bf) && (_le) ) \
+		{\
+			udp_send( (_bf), (_le), (struct sockaddr*)&((_rb)->to) , \
+				sizeof(struct sockaddr_in) ); \
+		} else { \
+			LOG(L_CRIT,"ERROR:attempt to send an empty buffer from %s (%d)"\
+				"(%p,%p,%d)\n",__FUNCTION__, __LINE__,(_rb),(_bf),(_le));\
+		}\
+	}\
 
 #define SEND_BUFFER( _rb ) SEND_PR_BUFFER( \
 	_rb,(_rb)->retr_buffer, (_rb)->bufflen )

+ 5 - 7
modules/tm/t_reply.c

@@ -22,22 +22,20 @@
  */
 int t_retransmit_reply( /* struct sip_msg* p_msg    */ )
 {
-
-	void *b;
+	static char b[BUF_SIZE];
 	int len;
 
+	if (!T->outbound_response.bufflen)
+		return 0;
+
 	LOCK_REPLIES( T );
-	len=T->outbound_response.bufflen;
-	b=pkg_malloc( len );
-	if (!b) {
+	if ( (len=T->outbound_response.bufflen)==0 || len>BUF_SIZE ) {
 		UNLOCK_REPLIES( T );
 		return -1;
 	}
 	memcpy( b, T->outbound_response.retr_buffer, len );
 	UNLOCK_REPLIES( T );
-
 	SEND_PR_BUFFER( & T->outbound_response, b, len );
-	pkg_free( b );
 	return 1;
 }
 

+ 1 - 1
modules/tm/tm.c

@@ -330,7 +330,7 @@ static int t_relay_to( struct sip_msg  *p_msg , char *str_ip , char *str_port)
 					DBG( "SER: new INVITE\n");
 					if (!t_send_reply( p_msg , 100 ,
 					"trying -- your call is important to us"))
-						DBG( "SER: ERROR: t_send_reply (100)\n");
+						LOG( L_CRIT,"SER: ERROR: t_send_reply (100)\n");
 				} else {
 					DBG( "SER: new transaction\n");
 				}

+ 1 - 1
test/th-uri.cfg

@@ -5,7 +5,7 @@
 #
 
 
-debug=9          # debug level (cmd line: -dddddddddd)
+debug=3          # debug level (cmd line: -dddddddddd)
 #fork=yes          # (cmd. line: -D)
 fork=no
 log_stderror=yes # (cmd line: -E)