Browse Source

static part of a transaction (struct cell) reduced by 216 bytes (for current
MAX_BRANCHES) :
- timer_link structer has no more payload field (calculated on the fly) ->
208 bytes less
- local, is_invite, noisy_ctimer merged as flags -> 8 bytes less

acc module update (for using the flags)

Bogdan-Andrei Iancu 21 years ago
parent
commit
0be6158b28

+ 14 - 16
modules/tm/h_table.c

@@ -37,47 +37,52 @@
  * 2003-12-04  global callbacks replaceed with callbacks per transaction;
  *             completion callback merged into them as LOCAL_COMPETED (bogdan)
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
+ * 2004-02-13  t->is_invite and t->local replaced with flags;
+ *             timer_link.payload removed (bogdan)
  */
 
-#include "defs.h"
+#include <stdlib.h>
 
 
-#include <stdlib.h>
 #include "../../mem/shm_mem.h"
 #include "../../hash_func.h"
-#include "h_table.h"
 #include "../../dprint.h"
 #include "../../md5utils.h"
-/* bogdan test */
 #include "../../ut.h"
 #include "../../globals.h"
 #include "../../error.h"
 #include "../../fifo_server.h"
+#include "defs.h"
 #include "t_reply.h"
 #include "t_cancel.h"
 #include "t_stats.h"
+#include "h_table.h"
 
 static enum kill_reason kr;
 
 /* pointer to the big table where all the transaction data
-   lives
-*/
-
+   lives */
 static struct s_table*  tm_table;
 
+
+
 void set_kr( enum kill_reason _kr )
 {
 	kr|=_kr;
 }
+
+
 enum kill_reason get_kr() {
 	return kr;
 }
 
+
 void lock_hash(int i) 
 {
 	lock(&tm_table->entrys[i].mutex);
 }
 
+
 void unlock_hash(int i) 
 {
 	unlock(&tm_table->entrys[i].mutex);
@@ -204,9 +209,6 @@ static void inline init_branches(struct cell *t)
 		uac->request.fr_timer.tg = TG_FR;
 		uac->request.retr_timer.tg = TG_RT;
 #endif
-		uac->request.retr_timer.payload = 
-			uac->request.fr_timer.payload = 
-			&uac->request;
 		uac->local_cancel=uac->request;
 	}
 }
@@ -232,8 +234,6 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 	new_cell->uas.response.retr_timer.tg=TG_RT;
 	new_cell->uas.response.fr_timer.tg=TG_FR;
 #endif
-	new_cell->uas.response.fr_timer.payload =
-	new_cell->uas.response.retr_timer.payload = &(new_cell->uas.response);
 	new_cell->uas.response.my_T=new_cell;
 
 	/* enter callback, which may potentially want to parse some stuff,
@@ -250,8 +250,6 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 	/* UAC */
 	init_branches(new_cell);
 
-	new_cell->wait_tl.payload = new_cell;
-	new_cell->dele_tl.payload = new_cell;
 	new_cell->relaied_reply_branch   = -1;
 	/* new_cell->T_canceled = T_UNDEFINED; */
 #ifdef EXTRA_DEBUG
@@ -359,7 +357,7 @@ void insert_into_hash_table_unsafe( struct cell * p_cell, unsigned int _hash )
 	/* update stats */
 	p_entry->cur_entries++;
 	p_entry->acc_entries++;
-	t_stats_new(p_cell->local);
+	t_stats_new( is_local(p_cell) );
 }
 
 
@@ -401,7 +399,7 @@ void remove_from_hash_table_unsafe( struct cell * p_cell)
 	}
 #	endif
 	p_entry->cur_entries--;
-	t_stats_deleted(p_cell->local);
+	t_stats_deleted( is_local(p_cell) );
 
 	/* unlock( &(p_entry->mutex) ); */
 }

+ 62 - 32
modules/tm/h_table.h

@@ -32,6 +32,8 @@
  * 2003-12-04  callbacks per transaction added; completion callback
  *             merge into them as LOCAL_COMPETED (bogdan)
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
+ * 2004-02-13: t->is_invite, t->local, t->noisy_ctimer replaced
+ *             with flags (bogdan)
  */
 
 #include "defs.h"
@@ -90,10 +92,10 @@ void unlock_hash(int i);
             from t_release_transaction
    REQ_EXIST means that this request is a retransmission which does not
             affect transactional state
-         
 */
 enum kill_reason { REQ_FWDED=1, REQ_RPLD=2, REQ_RLSD=4, REQ_EXIST=8 };
 
+
 typedef struct retr_buf
 {
 	int activ_type;
@@ -113,7 +115,6 @@ typedef struct retr_buf
 	/*the cell that containes this retrans_buff*/
 	struct cell* my_T;
 	unsigned int branch;
-
 }retr_buf_type;
 
 
@@ -149,10 +150,9 @@ typedef struct ua_client
 	   good for generating ACK/CANCEL */
 	str              uri;
 	/* if we store a reply (branch picking), this is where it is */
-	struct sip_msg 	*reply;
+	struct sip_msg  *reply;
 	/* if we don't store, we at least want to know the status */
-	int	last_received;
-
+	int             last_received;
 }ua_client_type;
 
 
@@ -162,6 +162,19 @@ struct totag_elem {
 	struct totag_elem *next;
 };
 
+
+
+/* transaction's falgs */
+/* is the transaction's request an INVITE? */
+#define T_IS_INVITE_FLAG     (1<<0)
+/* is this a trnasaction generated by local request? */
+#define T_IS_LOCAL_FLAG      (1<<1)
+/* set to one if you want to disallow silent transaction
+   dropping when C timer hits */
+#define T_NOISY_CTIMER_FLAG  (1<<2)
+
+
+
 /* transaction context */
 
 typedef struct cell
@@ -169,6 +182,23 @@ typedef struct cell
 	/* linking data */
 	struct cell*     next_cell;
 	struct cell*     prev_cell;
+	/* tells in which hash table entry the cell lives */
+	unsigned int  hash_index;
+	/* sequence number within hash collision slot */
+	unsigned int  label;
+	/* different information about the transaction */
+	unsigned int flags;
+
+	/* how many processes are currently processing this transaction ;
+	   note that only processes working on a request/reply belonging
+	   to a transaction increase ref_count -- timers don't, since we
+	   rely on transaction state machine to clean-up all but wait timer
+	   when entering WAIT state and the wait timer is the only place
+	   from which a transaction can be deleted (if ref_count==0); good
+	   for protecting from conditions in which wait_timer hits and
+	   tries to delete a transaction whereas at the same time 
+	   a delayed message belonging to the transaction is received */
+	volatile unsigned int ref_count;
 
 	/* needed for generating local ACK/CANCEL for local
 	   transactions; all but cseq_n include the entire
@@ -176,9 +206,6 @@ typedef struct cell
 	   local transactions, pointers point to outbound buffer,
 	   with proxied transactions to inbound request */
 	str from, callid, cseq_n, to;
-	/* a short-cut for remember whether this transaction needs
-	   INVITE-special handling (e.g., CANCEL, ACK, FR...)  */
-	short is_invite;
 	/* method shortcut -- for local transactions, pointer to
 	   outbound buffer, for proxies transactions pointer to
 	   original message; needed for reply matching */
@@ -187,22 +214,6 @@ typedef struct cell
 	/* head of callback list */
 	struct tmcb_head_list tmcb_hl;
 
-	/* how many processes are currently processing this transaction ;
-	   note that only processes working on a request/reply belonging
-	   to a transaction increase ref_count -- timers don't, since we
-	   rely on transaction state machine to clean-up all but wait timer
-	   when entering WAIT state and the wait timer is the only place
-	   from which a transaction can be deleted (if ref_count==0); good
-	   for protecting from conditions in which wait_timer hits and
-	   tries to delete a transaction whereas at the same time 
-	   a delayed message belonging to the transaction is received
-	*/
-	volatile unsigned int ref_count;
-	/* tells in which hash table entry the cell lives */
-	unsigned int  hash_index;
-	/* sequence number within hash collision slot */
-	unsigned int  label;
-
 	/* bindings to wait and delete timer */
 	struct timer_link wait_tl;
 	struct timer_link dele_tl;
@@ -224,12 +235,6 @@ typedef struct cell
 	unsigned int on_negative;
 	/* the onreply_route to be processed if registered to do so */
 	unsigned int on_reply;
-	/* set to one if you want to disallow silent transaction
-	   dropping when C timer hits
-	*/
-	int noisy_ctimer;
-	/* is it a local UAC transaction ? */
-	int local;
 
 	/* MD5checksum  (meaningful only if syn_branch=0 */
 	char md5[MD5_LEN];
@@ -238,8 +243,6 @@ typedef struct cell
 	/* scheduled for deletion ? */
 	short damocles;
 #endif
-	/* has the transaction been scheduled to die? */
-/*	enum kill_reason kr; */
 
 	/* to-tags of 200/INVITEs which were received from downstream and 
 	 * forwarded or passed to UAC; note that there can be arbitrarily 
@@ -272,6 +275,33 @@ struct s_table
 };
 
 
+#define list_entry(ptr, type, member) \
+	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+
+#define get_retr_timer_payload(_tl_) \
+	list_entry( _tl_, struct retr_buf, retr_timer)
+#define get_fr_timer_payload(_tl_) \
+	list_entry( _tl_, struct retr_buf, fr_timer)
+#define get_wait_timer_payload(_tl_) \
+	list_entry( _tl_, struct cell, wait_tl)
+#define get_dele_timer_payload(_tl_) \
+	list_entry( _tl_, struct cell, dele_tl)
+
+#define get_T_from_reply_rb(_rb_) \
+	list_entry( list_entry( _rb_, (struct ua_server), response),\
+		struct cell, uas)
+#define get_T_from_request_rb(_rb_, _br_) \
+	list_entry( list_entry( (rb_, (struct ua_client), request) - \
+		(_br_)*sizeof(struct retr_buf), struct cell, uas)
+#define get_T_from_cancel_rb(_rb_, _br_) \
+	list_entry( list_entry( (rb_, (struct ua_client), local_cancel) - \
+		(_br_)*sizeof(struct retr_buf), struct cell, uas)
+
+#define is_invite(_t_)           ((_t_)->flags&T_IS_INVITE_FLAG)
+#define is_local(_t_)            ((_t_)->flags&T_IS_LOCAL_FLAG)
+#define has_noisy_ctimer(_t_)    ((_t_)->flags&T_NOISY_CTIMER_FLAG)
+
+
 void set_kr( enum kill_reason kr );
 enum kill_reason get_kr();
 

+ 3 - 1
modules/tm/t_cancel.c

@@ -30,7 +30,7 @@
  * 2003-04-14  checking if a reply sent before cancel is initiated
  *             moved here (jiri)
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
- *
+ * 2004-02-13  timer_link.payload removed (bogdan)
  */
 
 #include <stdio.h> /* for FILE* in fifo_uac_cancel */
@@ -112,7 +112,9 @@ void cancel_branch( struct cell *t, int branch )
 	crb->buffer_len=len;
 	crb->dst=irb->dst;
 	crb->branch=branch;
+	/* TO_REMOVE
 	crb->retr_timer.payload=crb->fr_timer.payload=crb;
+	*/
 	/* label it as cancel so that FR timer can better now how to
 	   deal with it */
 	crb->activ_type=TYPE_LOCAL_CANCEL;

+ 3 - 3
modules/tm/t_funcs.c

@@ -39,6 +39,7 @@
  *  2003-04-25  do it (^) really everywhere (jiri)
  *  2003-04-26  do it (^) really really really everywhere (jiri)
  *  2003-07-07  added get_proto calls when proxy!=0 (andrei)
+ *  2004-02-13  t->is_invite and t->local replaced with flags (bogdan)
  */
 
 
@@ -274,10 +275,9 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
 	}
 
 	/* if replication flag is set, mark the transaction as local
-	   so that replies will not be relaied
-	*/
+	   so that replies will not be relaied */
 	t=get_t();
-	t->local=replicate;
+	if (replicate) t->flags|=T_IS_LOCAL_FLAG;
 
 	/* INVITE processing might take long, partcularly because of DNS
 	   look-ups -- let upstream know we're working on it */

+ 2 - 1
modules/tm/t_fwd.c

@@ -41,6 +41,7 @@
  *  2003-04-14  use protocol from uri (jiri)
  *  2003-12-04  global TM callbacks switched to per transaction callbacks
  *              (bogdan)
+ *  2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
  */
 
 #include "defs.h"
@@ -146,7 +147,7 @@ int add_blind_uac( /*struct cell *t*/ )
 		return -1;
 	}
 	/* make sure it will be replied */
-	t->noisy_ctimer=1; 
+	t->flags |= T_NOISY_CTIMER_FLAG;
 	t->nr_of_outgoings++;
 	/* start FR timer -- protocol set by default to PROTO_NONE,
        which means retransmission timer will not be started

+ 8 - 7
modules/tm/t_lookup.c

@@ -75,6 +75,7 @@
  * 2003-12-04  global TM callbacks switched to per transaction callbacks
  *             (bogdan)
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
+ * 2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
  */
 
 #include "defs.h"
@@ -763,7 +764,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 			! ((cseq_method.len==req_method.len 
 			&& memcmp( cseq_method.s, req_method.s, cseq_method.len )==0)
 			/* or it is a local cancel */
-			|| (is_cancel && p_cell->is_invite 
+			|| (is_cancel && is_invite(p_cell)
 				/* commented out -- should_cancel_branch set it to
 				   BUSY_BUFFER to avoid collisions with repliesl;
 				   thus, we test here by bbuffer size
@@ -787,17 +788,17 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 		 * enabled -- except callback customers, nobody cares about 
 		 * retransmissions of multiple 200/INV or ACK/200s
 		 */
-		if (p_cell->is_invite && p_msg->REPLY_STATUS>=200 
+		if (is_invite(p_cell) && p_msg->REPLY_STATUS>=200 
 		&& p_msg->REPLY_STATUS<300 
-		&& ( (!p_cell->local && 
+		&& ( (!is_local(p_cell) &&
 				has_tran_tmcbs(p_cell,TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) )
-			|| (p_cell->local && has_tran_tmcbs(p_cell,TMCB_LOCAL_COMPLETED))
+			|| (is_local(p_cell)&&has_tran_tmcbs(p_cell,TMCB_LOCAL_COMPLETED))
 		)) {
 			if (parse_headers(p_msg, HDR_TO, 0)==-1) {
 				LOG(L_ERR, "ERROR: t_reply_matching: to parsing failed\n");
 			}
 		}
-		if (!p_cell->local) {
+		if (!is_local(p_cell)) {
 			run_trans_callbacks( TMCB_RESPONSE_IN, T, T->uas.request, p_msg,
 				p_msg->REPLY_STATUS);
 		}
@@ -950,7 +951,7 @@ static inline void init_new_t(struct cell *new_cell, struct sip_msg *p_msg)
 		-shm_msg->cseq->name.s;
 
 	new_cell->method=new_cell->uas.request->first_line.u.request.method;
-	new_cell->is_invite=p_msg->REQ_METHOD==METHOD_INVITE;
+	if (p_msg->REQ_METHOD==METHOD_INVITE) new_cell->flags |= T_IS_INVITE_FLAG;
 	new_cell->on_negative=get_on_negative();
 	new_cell->on_reply=get_on_reply();
 }
@@ -1203,7 +1204,7 @@ int t_is_local(struct sip_msg* p_msg)
 	return -1;
     }
     
-    return t->local;
+    return is_local(t);
 }
 
 /* lookup a transaction by callid and cseq, parameters are pure

+ 4 - 3
modules/tm/t_msgbuilder.c

@@ -37,6 +37,7 @@
  *             avoid late ACK sending (jiri)
  * 2003-10-02  added via_builder set host/port support (andrei)
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
+ * 2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
  */
 
 #include "defs.h"
@@ -101,7 +102,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 		goto error;
 	branch_str.s=branch_buf;
 	branch_str.len=branch_len;
-	set_hostport(&hp, (Trans->local)?0:(Trans->uas.request));
+	set_hostport(&hp, (is_local(Trans))?0:(Trans->uas.request));
 	via=via_builder(&via_len, Trans->uac[branch].request.dst.send_sock,
 		&branch_str, 0, Trans->uac[branch].request.dst.proto, &hp );
 	if (!via)
@@ -117,7 +118,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 
 
 	/* copy'n'paste Route headers */
-	if (!Trans->local) {
+	if (!is_local(Trans)) {
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
 			 if (hdr->type==HDR_ROUTE)
 				*len+=hdr->len;
@@ -156,7 +157,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 	append_mem_block( p, method, method_len );
 	append_mem_block( p, CRLF, CRLF_LEN );
 
-	if (!Trans->local)  {
+	if (!is_local(Trans))  {
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
 			if(hdr->type==HDR_ROUTE) {
 				append_mem_block(p, hdr->name.s, hdr->len );

+ 21 - 23
modules/tm/t_reply.c

@@ -58,6 +58,7 @@
  *  2003-11-05  flag context updated from failure/reply handlers back
  *              to transaction context (jiri)
  *  2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
+ *  2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
  */
 
 
@@ -287,7 +288,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 	{
 		DBG("DEBUG: t_reply: response building failed\n");
 		/* determine if there are some branches to be cancelled */
-		if (trans->is_invite) {
+		if ( is_invite(trans) ) {
 			if (lock) LOCK_REPLIES( trans );
 			which_cancel(trans, &cancel_bitmap );
 			if (lock) UNLOCK_REPLIES( trans );
@@ -298,7 +299,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 
 	cancel_bitmap=0;
 	if (lock) LOCK_REPLIES( trans );
-	if (trans->is_invite) which_cancel(trans, &cancel_bitmap );
+	if ( is_invite(trans) ) which_cancel(trans, &cancel_bitmap );
 	if (trans->uas.status>=200) {
 		LOG( L_ERR, "ERROR: t_reply: can't generate %d reply"
 			" when a final %d was sent out\n", code, trans->uas.status);
@@ -332,7 +333,7 @@ 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 (trans->local) {
+		if ( is_local(trans) ) {
 			DBG("DEBUG: local transaction completed from _reply\n");
 			if ( has_tran_tmcbs(trans, TMCB_LOCAL_COMPLETED) )
 				run_trans_callbacks( TMCB_LOCAL_COMPLETED, trans,
@@ -344,7 +345,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 		}
 
 		cleanup_uac_timers( trans );
-		if (trans->is_invite) cancel_uacs( trans, cancel_bitmap );
+		if (is_invite(trans)) cancel_uacs( trans, cancel_bitmap );
 		set_final_timer(  trans );
 	}
 
@@ -370,7 +371,7 @@ error2:
 error:
 	/* do UAC cleanup */
 	cleanup_uac_timers( trans );
-	if (trans->is_invite) cancel_uacs( trans, cancel_bitmap );
+	if ( is_invite(trans) ) cancel_uacs( trans, cancel_bitmap );
 	/* we did not succeed -- put the transaction on wait */
 	put_on_wait(trans);
 	return -1;
@@ -605,7 +606,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 	   out
 	*/
 	DBG("->>>>>>>>> T_code=%d, new_code=%d\n",Trans->uas.status,new_code);
-	inv_through=new_code>=200 && new_code<300 && Trans->is_invite;
+	inv_through=new_code>=200 && new_code<300 && is_invite(Trans);
 	/* if final response sent out, allow only INVITE 2xx  */
 	if ( Trans->uas.status >= 200 ) {
 		if (inv_through) {
@@ -784,7 +785,7 @@ int t_reply_unsafe( struct cell *t, struct sip_msg* p_msg, unsigned int code,
 
 void set_final_timer( /* struct s_table *h_table, */ struct cell *t )
 {
-	if ( !t->local && t->uas.request->REQ_METHOD==METHOD_INVITE ) {
+	if ( !is_local(t) && t->uas.request->REQ_METHOD==METHOD_INVITE ) {
 		/* crank timers for negative replies */
 		if (t->uas.status>=300) {
 			start_retr(&t->uas.response);
@@ -962,7 +963,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		t->uas.status = relayed_code;
 		t->relaied_reply_branch = relay;
 
-		if (t->is_invite && relayed_msg!=FAKED_REPLY
+		if (is_invite(t) && relayed_msg!=FAKED_REPLY
 		&& relayed_code>=200 && relayed_code < 300
 		&& has_tran_tmcbs( t, TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) ) {
 			totag_retr=update_totag_set(t, relayed_msg);
@@ -997,10 +998,9 @@ error02:
 error01:
 	t_reply_unsafe( t, t->uas.request, 500, "Reply processing error" );
 	UNLOCK_REPLIES(t);
-	if (t->is_invite) cancel_uacs( t, *cancel_bitmap );
+	if (is_invite(t)) cancel_uacs( t, *cancel_bitmap );
 	/* a serious error occured -- attempt to send an error reply;
-	   it will take care of clean-ups 
-	*/
+	   it will take care of clean-ups  */
 
 	/* failure */
 	return RPS_ERROR;
@@ -1048,7 +1048,7 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		}
 		t->uas.status = winning_code;
 		update_reply_stats( winning_code );
-		if (t->is_invite && winning_msg!=FAKED_REPLY
+		if (is_invite(t) && winning_msg!=FAKED_REPLY
 		&& winning_code>=200 && winning_code <300
 		&& has_tran_tmcbs(t,TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) )  {
 			totag_retr=update_totag_set(t, winning_msg);
@@ -1113,13 +1113,13 @@ int reply_received( struct sip_msg  *p_msg )
 	DBG("DEBUG: t_on_reply: org. status uas=%d, "
 		"uac[%d]=%d local=%d is_invite=%d)\n",
 		t->uas.status, branch, uac->last_received, 
-		t->local, t->is_invite);
+		is_local(t), is_invite(t));
 
 	/* it's a cancel ... ? */
 	if (get_cseq(p_msg)->method.len==CANCEL_LEN 
 		&& memcmp( get_cseq(p_msg)->method.s, CANCEL, CANCEL_LEN)==0
 		/* .. which is not e2e ? ... */
-		&& t->is_invite ) {
+		&& is_invite(t) ) {
 			/* ... then just stop timers */
 			reset_timer( &uac->local_cancel.retr_timer);
 			if ( msg_status >= 200 )
@@ -1135,12 +1135,10 @@ int reply_received( struct sip_msg  *p_msg )
 	/* stop final response timer only if I got a final response */
 	if ( msg_status >= 200 )
 		reset_timer( &uac->request.fr_timer);
-        
-        /* acknowledge negative INVITE replies (do it before detailed
-           on_reply processing, which may take very long, like if it
-           is attempted to establish a TCP connection to a fail-over dst
-        */
-	if (t->is_invite && (msg_status>=300 || (t->local && msg_status>=200))) {
+		/* acknowledge negative INVITE replies (do it before detailed
+		 * on_reply processing, which may take very long, like if it
+		 * is attempted to establish a TCP connection to a fail-over dst */
+	if (is_invite(t) && (msg_status>=300 || (is_local(t) && msg_status>=200))){
 		ack = build_ack( p_msg, t, branch, &ack_len);
 		if (ack) {
 			SEND_PR_BUFFER( &uac->request, ack, ack_len );
@@ -1161,7 +1159,7 @@ int reply_received( struct sip_msg  *p_msg )
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
 	}
 	LOCK_REPLIES( t );
-	if (t->local) {
+	if ( is_local(t) ) {
 		reply_status=local_reply( t, p_msg, branch, msg_status, &cancel_bitmap );
 	} else {
 		reply_status=relay_reply( t, p_msg, branch, msg_status, 
@@ -1177,14 +1175,14 @@ int reply_received( struct sip_msg  *p_msg )
 		   be still pending branches ...
 		*/
 		cleanup_uac_timers( t );	
-		if (t->is_invite) cancel_uacs( t, cancel_bitmap );
+		if (is_invite(t)) cancel_uacs( t, cancel_bitmap );
 		/* FR for negative INVITES, WAIT anything else */
 		set_final_timer(  t );
 	} 
 
 	/* update FR/RETR timers on provisional replies */
 	if (msg_status<200) { /* provisional now */
-		if (t->is_invite) { 
+		if (is_invite(t)) {
 			/* invite: change FR to longer FR_INV, do not
 			   attempt to restart retransmission any more
 			*/

+ 27 - 27
modules/tm/timer.c

@@ -96,6 +96,8 @@
  * History:
  * --------
  *  2003-06-27  timers are not unlinked if timerlist is 0 (andrei)
+ *  2004-02-13  t->is_invite, t->local, t->noisy_ctimer replaced;
+ *              timer_link.payload removed (bogdan)
  */
 
 #include "defs.h"
@@ -239,10 +241,10 @@ static void fake_reply(struct cell *t, int branch, int code )
 	short do_cancel_branch;
 	enum rps reply_status;
 
-	do_cancel_branch=t->is_invite && should_cancel_branch(t, branch);
+	do_cancel_branch = is_invite(t) && should_cancel_branch(t, branch);
 
 	cancel_bitmap=do_cancel_branch ? 1<<branch : 0;
-	if (t->local) {
+	if ( is_local(t) ) {
 		reply_status=local_reply( t, FAKED_REPLY, branch, 
 			code, &cancel_bitmap );
 	} else {
@@ -273,12 +275,12 @@ static void fake_reply(struct cell *t, int branch, int code )
 
 
 
-inline static void retransmission_handler( void *attr)
+inline static void retransmission_handler( struct timer_link *retr_tl )
 {
 	struct retr_buf* r_buf ;
 	enum lists id;
 
-	r_buf = (struct retr_buf*)attr;
+	r_buf = get_retr_timer_payload(retr_tl);
 #ifdef EXTRA_DEBUG
 	if (r_buf->my_T->damocles) {
 		LOG( L_ERR, "ERROR: transaction %p scheduled for deletion and"
@@ -290,7 +292,7 @@ inline static void retransmission_handler( void *attr)
 	/*the transaction is already removed from RETRANSMISSION_LIST by timer*/
 	/* retransmision */
 	if ( r_buf->activ_type==TYPE_LOCAL_CANCEL 
-		|| r_buf->activ_type==0 ) {
+		|| r_buf->activ_type==TYPE_REQUEST ) {
 			DBG("DEBUG: retransmission_handler : "
 				"request resending (t=%p, %.9s ... )\n", 
 				r_buf->my_T, r_buf->buffer);
@@ -309,9 +311,8 @@ inline static void retransmission_handler( void *attr)
 	id = r_buf->retr_list;
 	r_buf->retr_list = id < RT_T2 ? id + 1 : RT_T2;
 	
-	r_buf->retr_timer.timer_list= NULL; /* set to NULL so that set_timer
-										   will work */
-	set_timer(&(r_buf->retr_timer),id < RT_T2 ? id + 1 : RT_T2 );
+	retr_tl->timer_list= NULL; /* set to NULL so that set_timer will work */
+	set_timer( retr_tl, id < RT_T2 ? id + 1 : RT_T2 );
 
 	DBG("DEBUG: retransmission_handler : done\n");
 }
@@ -319,18 +320,18 @@ inline static void retransmission_handler( void *attr)
 
 
 
-inline static void final_response_handler( void *attr)
+inline static void final_response_handler( struct timer_link *fr_tl )
 {
 	int silent;
 	struct retr_buf* r_buf;
 	struct cell *t;
 
-	r_buf = (struct retr_buf*)attr;
-	if (r_buf==0){
+	if (fr_tl==0){
 		/* or BUG?, ignoring it for now */
 		LOG(L_CRIT, "ERROR: final_response_handler(0) called\n");
 		return;
 	}
+	r_buf = get_fr_timer_payload(fr_tl);
 	t=r_buf->my_T;
 
 #	ifdef EXTRA_DEBUG
@@ -374,22 +375,22 @@ inline static void final_response_handler( void *attr)
 	   world */
 	silent=
 		/* not for UACs */
-		!t->local
+		!is_local(t)
 		/* invites only */
-		&& t->is_invite
+		&& is_invite(t)
 		/* parallel forking does not allow silent state discarding */
 		&& t->nr_of_outgoings==1
 		/* on_negativ reply handler not installed -- serial forking 
 		 * could occur otherwise */
 		&& t->on_negative==0
 		/* the same for FAILURE callbacks */
-		&& (t->tmcb_hl.reg_types&(TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE))==0
+		&& !has_tran_tmcbs( t, TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE) 
 		/* something received -- we will not be silent on error */
 		&& t->uac[r_buf->branch].last_received>0
 		/* don't go silent if disallowed globally ... */
 		&& noisy_ctimer==0
 		/* ... or for this particular transaction */
-		&& t->noisy_ctimer==0;
+		&& has_noisy_ctimer(t);
 	if (silent) {
 		UNLOCK_REPLIES(t);
 		DBG("DEBUG: FR_handler: transaction silently dropped (%p)\n",t);
@@ -403,6 +404,8 @@ inline static void final_response_handler( void *attr)
 	DBG("DEBUG: final_response_handler : done\n");
 }
 
+
+
 void cleanup_localcancel_timers( struct cell *t )
 {
 	int i;
@@ -413,10 +416,11 @@ void cleanup_localcancel_timers( struct cell *t )
 }
 
 
-inline static void wait_handler( void *attr)
+inline static void wait_handler( struct timer_link *wait_tl )
 {
-	struct cell *p_cell = (struct cell*)attr;
+	struct cell *p_cell;
 
+	p_cell = get_wait_timer_payload( wait_tl );
 #ifdef EXTRA_DEBUG
 	if (p_cell->damocles) {
 		LOG( L_ERR, "ERROR: transaction %p scheduled for deletion and"
@@ -427,7 +431,7 @@ inline static void wait_handler( void *attr)
 #endif
 
 	/* stop cancel timers if any running */
-	if (p_cell->is_invite) cleanup_localcancel_timers( p_cell );
+	if ( is_invite(p_cell) ) cleanup_localcancel_timers( p_cell );
 
 	/* the transaction is already removed from WT_LIST by the timer */
 	/* remove the cell from the hash table */
@@ -445,11 +449,11 @@ inline static void wait_handler( void *attr)
 
 
 
-
-inline static void delete_handler( void *attr)
+inline static void delete_handler( struct timer_link *dele_tl )
 {
-	struct cell *p_cell = (struct cell*)attr;
+	struct cell *p_cell;
 
+	p_cell = get_dele_timer_payload( dele_tl );
 	DBG("DEBUG: delete_handler : removing %p \n", p_cell );
 #ifdef EXTRA_DEBUG
 	if (p_cell->damocles==0) {
@@ -498,7 +502,7 @@ void unlink_timer_lists()
 	   (they are no more accessible from enrys) */
 	while (tl!=end) {
 		tmp=tl->next_tl;
-		free_cell((struct cell*)tl->payload);
+		free_cell( get_dele_timer_payload(tl) );
 		tl=tmp;
 	}
 	
@@ -864,7 +868,7 @@ static void unlink_timers( struct cell *t )
 		DBG("DEBUG: timer routine:%d,tl=%p next=%p\n",\
 			id,(_tl),tmp_tl);\
 		if ((_tl)->time_out>TIMER_DELETED) \
-			(_handler)( (_tl)->payload );\
+			(_handler)( _tl );\
 		(_tl) = tmp_tl;\
 	}
 
@@ -877,10 +881,6 @@ void timer_routine(unsigned int ticks , void * attr)
 	struct timer_link *tl, *tmp_tl;
 	int                id;
 
-#ifdef BOGDAN_TRIFLE
-	DBG(" %d \n",ticks);
-#endif
-
 	for( id=0 ; id<NR_OF_TIMER_LISTS ; id++ )
 	{
 		/* to waste as little time in lock as possible, detach list

+ 5 - 5
modules/tm/timer.h

@@ -28,6 +28,7 @@
  * History:
  * --------
  *  2003-09-12  timer_link.tg exists only if EXTRA_DEBUG (andrei)
+ *  2004-02-13  timer_link.payload removed (bogdan)
  */
 
 
@@ -62,11 +63,10 @@ enum lists
    links to neighbours and timer value */
 typedef struct timer_link
 {
-	struct timer_link *next_tl;
-	struct timer_link *prev_tl;
-	volatile unsigned int       time_out;
-	void              *payload;
-	struct timer      *timer_list;
+	struct timer_link     *next_tl;
+	struct timer_link     *prev_tl;
+	volatile unsigned int  time_out;
+	struct timer          *timer_list;
 #ifdef EXTRA_DEBUG
 	enum timer_groups  tg;
 #endif

+ 1 - 1
modules/tm/tm.c

@@ -452,7 +452,7 @@ static int script_init( struct sip_msg *foo, void *bar)
 
 static int mod_init(void)
 {
-	DBG( "TM - initializing...\n");
+	DBG( "TM - (size of cell=%d) initializing...\n",sizeof(struct cell));
 	/* checking if we have sufficient bitmap capacity for given
 	   maximum number of  branches */
 	if (MAX_BRANCHES+1>31) {

+ 5 - 4
modules/tm/uac.c

@@ -48,6 +48,7 @@
  *  2003-12-03  completion filed removed from transaction and uac callbacks
  *              merged in transaction callbacks as LOCAL_COMPLETED (bogdan)
  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
+ *  2004-02-13  t->is_invite, t->local, t->noisy_ctimer replaced (bogdan)
  */
 
 #include <string.h>
@@ -202,11 +203,11 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
 		goto error2;
 	}
 
-	new_cell->is_invite =
-		method->len==INVITE_LEN && memcmp(method->s, INVITE, INVITE_LEN)==0;
-	new_cell->local= 1;
+	if (method->len==INVITE_LEN && memcmp(method->s, INVITE, INVITE_LEN)==0)
+		new_cell->flags |= T_IS_INVITE_FLAG;
+	new_cell->flags |= T_IS_LOCAL_FLAG;
 	set_kr(REQ_FWDED);
-	
+
 	request = &new_cell->uac[0].request;
 	request->dst.to = to_su;
 	request->dst.send_sock = send_sock;