Browse code

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 authored on 13/02/2004 18:21:33
Showing 12 changed files
... ...
@@ -37,47 +37,52 @@
37 37
  * 2003-12-04  global callbacks replaceed with callbacks per transaction;
38 38
  *             completion callback merged into them as LOCAL_COMPETED (bogdan)
39 39
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
40
+ * 2004-02-13  t->is_invite and t->local replaced with flags;
41
+ *             timer_link.payload removed (bogdan)
40 42
  */
41 43
 
42
-#include "defs.h"
44
+#include <stdlib.h>
43 45
 
44 46
 
45
-#include <stdlib.h>
46 47
 #include "../../mem/shm_mem.h"
47 48
 #include "../../hash_func.h"
48
-#include "h_table.h"
49 49
 #include "../../dprint.h"
50 50
 #include "../../md5utils.h"
51
-/* bogdan test */
52 51
 #include "../../ut.h"
53 52
 #include "../../globals.h"
54 53
 #include "../../error.h"
55 54
 #include "../../fifo_server.h"
55
+#include "defs.h"
56 56
 #include "t_reply.h"
57 57
 #include "t_cancel.h"
58 58
 #include "t_stats.h"
59
+#include "h_table.h"
59 60
 
60 61
 static enum kill_reason kr;
61 62
 
62 63
 /* pointer to the big table where all the transaction data
63
-   lives
64
-*/
65
-
64
+   lives */
66 65
 static struct s_table*  tm_table;
67 66
 
67
+
68
+
68 69
 void set_kr( enum kill_reason _kr )
69 70
 {
70 71
 	kr|=_kr;
71 72
 }
73
+
74
+
72 75
 enum kill_reason get_kr() {
73 76
 	return kr;
74 77
 }
75 78
 
79
+
76 80
 void lock_hash(int i) 
77 81
 {
78 82
 	lock(&tm_table->entrys[i].mutex);
79 83
 }
80 84
 
85
+
81 86
 void unlock_hash(int i) 
82 87
 {
83 88
 	unlock(&tm_table->entrys[i].mutex);
... ...
@@ -204,9 +209,6 @@ static void inline init_branches(struct cell *t)
204 209
 		uac->request.fr_timer.tg = TG_FR;
205 210
 		uac->request.retr_timer.tg = TG_RT;
206 211
 #endif
207
-		uac->request.retr_timer.payload = 
208
-			uac->request.fr_timer.payload = 
209
-			&uac->request;
210 212
 		uac->local_cancel=uac->request;
211 213
 	}
212 214
 }
... ...
@@ -232,8 +234,6 @@ struct cell*  build_cell( struct sip_msg* p_msg )
232 234
 	new_cell->uas.response.retr_timer.tg=TG_RT;
233 235
 	new_cell->uas.response.fr_timer.tg=TG_FR;
234 236
 #endif
235
-	new_cell->uas.response.fr_timer.payload =
236
-	new_cell->uas.response.retr_timer.payload = &(new_cell->uas.response);
237 237
 	new_cell->uas.response.my_T=new_cell;
238 238
 
239 239
 	/* enter callback, which may potentially want to parse some stuff,
... ...
@@ -250,8 +250,6 @@ struct cell*  build_cell( struct sip_msg* p_msg )
250 250
 	/* UAC */
251 251
 	init_branches(new_cell);
252 252
 
253
-	new_cell->wait_tl.payload = new_cell;
254
-	new_cell->dele_tl.payload = new_cell;
255 253
 	new_cell->relaied_reply_branch   = -1;
256 254
 	/* new_cell->T_canceled = T_UNDEFINED; */
257 255
 #ifdef EXTRA_DEBUG
... ...
@@ -359,7 +357,7 @@ void insert_into_hash_table_unsafe( struct cell * p_cell, unsigned int _hash )
359 357
 	/* update stats */
360 358
 	p_entry->cur_entries++;
361 359
 	p_entry->acc_entries++;
362
-	t_stats_new(p_cell->local);
360
+	t_stats_new( is_local(p_cell) );
363 361
 }
364 362
 
365 363
 
... ...
@@ -401,7 +399,7 @@ void remove_from_hash_table_unsafe( struct cell * p_cell)
401 399
 	}
402 400
 #	endif
403 401
 	p_entry->cur_entries--;
404
-	t_stats_deleted(p_cell->local);
402
+	t_stats_deleted( is_local(p_cell) );
405 403
 
406 404
 	/* unlock( &(p_entry->mutex) ); */
407 405
 }
... ...
@@ -32,6 +32,8 @@
32 32
  * 2003-12-04  callbacks per transaction added; completion callback
33 33
  *             merge into them as LOCAL_COMPETED (bogdan)
34 34
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
35
+ * 2004-02-13: t->is_invite, t->local, t->noisy_ctimer replaced
36
+ *             with flags (bogdan)
35 37
  */
36 38
 
37 39
 #include "defs.h"
... ...
@@ -90,10 +92,10 @@ void unlock_hash(int i);
90 92
             from t_release_transaction
91 93
    REQ_EXIST means that this request is a retransmission which does not
92 94
             affect transactional state
93
-         
94 95
 */
95 96
 enum kill_reason { REQ_FWDED=1, REQ_RPLD=2, REQ_RLSD=4, REQ_EXIST=8 };
96 97
 
98
+
97 99
 typedef struct retr_buf
98 100
 {
99 101
 	int activ_type;
... ...
@@ -113,7 +115,6 @@ typedef struct retr_buf
113 115
 	/*the cell that containes this retrans_buff*/
114 116
 	struct cell* my_T;
115 117
 	unsigned int branch;
116
-
117 118
 }retr_buf_type;
118 119
 
119 120
 
... ...
@@ -149,10 +150,9 @@ typedef struct ua_client
149 150
 	   good for generating ACK/CANCEL */
150 151
 	str              uri;
151 152
 	/* if we store a reply (branch picking), this is where it is */
152
-	struct sip_msg 	*reply;
153
+	struct sip_msg  *reply;
153 154
 	/* if we don't store, we at least want to know the status */
154
-	int	last_received;
155
-
155
+	int             last_received;
156 156
 }ua_client_type;
157 157
 
158 158
 
... ...
@@ -162,6 +162,19 @@ struct totag_elem {
162 162
 	struct totag_elem *next;
163 163
 };
164 164
 
165
+
166
+
167
+/* transaction's falgs */
168
+/* is the transaction's request an INVITE? */
169
+#define T_IS_INVITE_FLAG     (1<<0)
170
+/* is this a trnasaction generated by local request? */
171
+#define T_IS_LOCAL_FLAG      (1<<1)
172
+/* set to one if you want to disallow silent transaction
173
+   dropping when C timer hits */
174
+#define T_NOISY_CTIMER_FLAG  (1<<2)
175
+
176
+
177
+
165 178
 /* transaction context */
166 179
 
167 180
 typedef struct cell
... ...
@@ -169,6 +182,23 @@ typedef struct cell
169 182
 	/* linking data */
170 183
 	struct cell*     next_cell;
171 184
 	struct cell*     prev_cell;
185
+	/* tells in which hash table entry the cell lives */
186
+	unsigned int  hash_index;
187
+	/* sequence number within hash collision slot */
188
+	unsigned int  label;
189
+	/* different information about the transaction */
190
+	unsigned int flags;
191
+
192
+	/* how many processes are currently processing this transaction ;
193
+	   note that only processes working on a request/reply belonging
194
+	   to a transaction increase ref_count -- timers don't, since we
195
+	   rely on transaction state machine to clean-up all but wait timer
196
+	   when entering WAIT state and the wait timer is the only place
197
+	   from which a transaction can be deleted (if ref_count==0); good
198
+	   for protecting from conditions in which wait_timer hits and
199
+	   tries to delete a transaction whereas at the same time 
200
+	   a delayed message belonging to the transaction is received */
201
+	volatile unsigned int ref_count;
172 202
 
173 203
 	/* needed for generating local ACK/CANCEL for local
174 204
 	   transactions; all but cseq_n include the entire
... ...
@@ -176,9 +206,6 @@ typedef struct cell
176 206
 	   local transactions, pointers point to outbound buffer,
177 207
 	   with proxied transactions to inbound request */
178 208
 	str from, callid, cseq_n, to;
179
-	/* a short-cut for remember whether this transaction needs
180
-	   INVITE-special handling (e.g., CANCEL, ACK, FR...)  */
181
-	short is_invite;
182 209
 	/* method shortcut -- for local transactions, pointer to
183 210
 	   outbound buffer, for proxies transactions pointer to
184 211
 	   original message; needed for reply matching */
... ...
@@ -187,22 +214,6 @@ typedef struct cell
187 214
 	/* head of callback list */
188 215
 	struct tmcb_head_list tmcb_hl;
189 216
 
190
-	/* how many processes are currently processing this transaction ;
191
-	   note that only processes working on a request/reply belonging
192
-	   to a transaction increase ref_count -- timers don't, since we
193
-	   rely on transaction state machine to clean-up all but wait timer
194
-	   when entering WAIT state and the wait timer is the only place
195
-	   from which a transaction can be deleted (if ref_count==0); good
196
-	   for protecting from conditions in which wait_timer hits and
197
-	   tries to delete a transaction whereas at the same time 
198
-	   a delayed message belonging to the transaction is received
199
-	*/
200
-	volatile unsigned int ref_count;
201
-	/* tells in which hash table entry the cell lives */
202
-	unsigned int  hash_index;
203
-	/* sequence number within hash collision slot */
204
-	unsigned int  label;
205
-
206 217
 	/* bindings to wait and delete timer */
207 218
 	struct timer_link wait_tl;
208 219
 	struct timer_link dele_tl;
... ...
@@ -224,12 +235,6 @@ typedef struct cell
224 235
 	unsigned int on_negative;
225 236
 	/* the onreply_route to be processed if registered to do so */
226 237
 	unsigned int on_reply;
227
-	/* set to one if you want to disallow silent transaction
228
-	   dropping when C timer hits
229
-	*/
230
-	int noisy_ctimer;
231
-	/* is it a local UAC transaction ? */
232
-	int local;
233 238
 
234 239
 	/* MD5checksum  (meaningful only if syn_branch=0 */
235 240
 	char md5[MD5_LEN];
... ...
@@ -238,8 +243,6 @@ typedef struct cell
238 243
 	/* scheduled for deletion ? */
239 244
 	short damocles;
240 245
 #endif
241
-	/* has the transaction been scheduled to die? */
242
-/*	enum kill_reason kr; */
243 246
 
244 247
 	/* to-tags of 200/INVITEs which were received from downstream and 
245 248
 	 * forwarded or passed to UAC; note that there can be arbitrarily 
... ...
@@ -272,6 +275,33 @@ struct s_table
272 275
 };
273 276
 
274 277
 
278
+#define list_entry(ptr, type, member) \
279
+	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
280
+
281
+#define get_retr_timer_payload(_tl_) \
282
+	list_entry( _tl_, struct retr_buf, retr_timer)
283
+#define get_fr_timer_payload(_tl_) \
284
+	list_entry( _tl_, struct retr_buf, fr_timer)
285
+#define get_wait_timer_payload(_tl_) \
286
+	list_entry( _tl_, struct cell, wait_tl)
287
+#define get_dele_timer_payload(_tl_) \
288
+	list_entry( _tl_, struct cell, dele_tl)
289
+
290
+#define get_T_from_reply_rb(_rb_) \
291
+	list_entry( list_entry( _rb_, (struct ua_server), response),\
292
+		struct cell, uas)
293
+#define get_T_from_request_rb(_rb_, _br_) \
294
+	list_entry( list_entry( (rb_, (struct ua_client), request) - \
295
+		(_br_)*sizeof(struct retr_buf), struct cell, uas)
296
+#define get_T_from_cancel_rb(_rb_, _br_) \
297
+	list_entry( list_entry( (rb_, (struct ua_client), local_cancel) - \
298
+		(_br_)*sizeof(struct retr_buf), struct cell, uas)
299
+
300
+#define is_invite(_t_)           ((_t_)->flags&T_IS_INVITE_FLAG)
301
+#define is_local(_t_)            ((_t_)->flags&T_IS_LOCAL_FLAG)
302
+#define has_noisy_ctimer(_t_)    ((_t_)->flags&T_NOISY_CTIMER_FLAG)
303
+
304
+
275 305
 void set_kr( enum kill_reason kr );
276 306
 enum kill_reason get_kr();
277 307
 
... ...
@@ -30,7 +30,7 @@
30 30
  * 2003-04-14  checking if a reply sent before cancel is initiated
31 31
  *             moved here (jiri)
32 32
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
33
- *
33
+ * 2004-02-13  timer_link.payload removed (bogdan)
34 34
  */
35 35
 
36 36
 #include <stdio.h> /* for FILE* in fifo_uac_cancel */
... ...
@@ -112,7 +112,9 @@ void cancel_branch( struct cell *t, int branch )
112 112
 	crb->buffer_len=len;
113 113
 	crb->dst=irb->dst;
114 114
 	crb->branch=branch;
115
+	/* TO_REMOVE
115 116
 	crb->retr_timer.payload=crb->fr_timer.payload=crb;
117
+	*/
116 118
 	/* label it as cancel so that FR timer can better now how to
117 119
 	   deal with it */
118 120
 	crb->activ_type=TYPE_LOCAL_CANCEL;
... ...
@@ -39,6 +39,7 @@
39 39
  *  2003-04-25  do it (^) really everywhere (jiri)
40 40
  *  2003-04-26  do it (^) really really really everywhere (jiri)
41 41
  *  2003-07-07  added get_proto calls when proxy!=0 (andrei)
42
+ *  2004-02-13  t->is_invite and t->local replaced with flags (bogdan)
42 43
  */
43 44
 
44 45
 
... ...
@@ -274,10 +275,9 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
274 275
 	}
275 276
 
276 277
 	/* if replication flag is set, mark the transaction as local
277
-	   so that replies will not be relaied
278
-	*/
278
+	   so that replies will not be relaied */
279 279
 	t=get_t();
280
-	t->local=replicate;
280
+	if (replicate) t->flags|=T_IS_LOCAL_FLAG;
281 281
 
282 282
 	/* INVITE processing might take long, partcularly because of DNS
283 283
 	   look-ups -- let upstream know we're working on it */
... ...
@@ -41,6 +41,7 @@
41 41
  *  2003-04-14  use protocol from uri (jiri)
42 42
  *  2003-12-04  global TM callbacks switched to per transaction callbacks
43 43
  *              (bogdan)
44
+ *  2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
44 45
  */
45 46
 
46 47
 #include "defs.h"
... ...
@@ -146,7 +147,7 @@ int add_blind_uac( /*struct cell *t*/ )
146 147
 		return -1;
147 148
 	}
148 149
 	/* make sure it will be replied */
149
-	t->noisy_ctimer=1; 
150
+	t->flags |= T_NOISY_CTIMER_FLAG;
150 151
 	t->nr_of_outgoings++;
151 152
 	/* start FR timer -- protocol set by default to PROTO_NONE,
152 153
        which means retransmission timer will not be started
... ...
@@ -75,6 +75,7 @@
75 75
  * 2003-12-04  global TM callbacks switched to per transaction callbacks
76 76
  *             (bogdan)
77 77
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
78
+ * 2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
78 79
  */
79 80
 
80 81
 #include "defs.h"
... ...
@@ -763,7 +764,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
763 764
 			! ((cseq_method.len==req_method.len 
764 765
 			&& memcmp( cseq_method.s, req_method.s, cseq_method.len )==0)
765 766
 			/* or it is a local cancel */
766
-			|| (is_cancel && p_cell->is_invite 
767
+			|| (is_cancel && is_invite(p_cell)
767 768
 				/* commented out -- should_cancel_branch set it to
768 769
 				   BUSY_BUFFER to avoid collisions with repliesl;
769 770
 				   thus, we test here by bbuffer size
... ...
@@ -787,17 +788,17 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
787 788
 		 * enabled -- except callback customers, nobody cares about 
788 789
 		 * retransmissions of multiple 200/INV or ACK/200s
789 790
 		 */
790
-		if (p_cell->is_invite && p_msg->REPLY_STATUS>=200 
791
+		if (is_invite(p_cell) && p_msg->REPLY_STATUS>=200 
791 792
 		&& p_msg->REPLY_STATUS<300 
792
-		&& ( (!p_cell->local && 
793
+		&& ( (!is_local(p_cell) &&
793 794
 				has_tran_tmcbs(p_cell,TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) )
794
-			|| (p_cell->local && has_tran_tmcbs(p_cell,TMCB_LOCAL_COMPLETED))
795
+			|| (is_local(p_cell)&&has_tran_tmcbs(p_cell,TMCB_LOCAL_COMPLETED))
795 796
 		)) {
796 797
 			if (parse_headers(p_msg, HDR_TO, 0)==-1) {
797 798
 				LOG(L_ERR, "ERROR: t_reply_matching: to parsing failed\n");
798 799
 			}
799 800
 		}
800
-		if (!p_cell->local) {
801
+		if (!is_local(p_cell)) {
801 802
 			run_trans_callbacks( TMCB_RESPONSE_IN, T, T->uas.request, p_msg,
802 803
 				p_msg->REPLY_STATUS);
803 804
 		}
... ...
@@ -950,7 +951,7 @@ static inline void init_new_t(struct cell *new_cell, struct sip_msg *p_msg)
950 951
 		-shm_msg->cseq->name.s;
951 952
 
952 953
 	new_cell->method=new_cell->uas.request->first_line.u.request.method;
953
-	new_cell->is_invite=p_msg->REQ_METHOD==METHOD_INVITE;
954
+	if (p_msg->REQ_METHOD==METHOD_INVITE) new_cell->flags |= T_IS_INVITE_FLAG;
954 955
 	new_cell->on_negative=get_on_negative();
955 956
 	new_cell->on_reply=get_on_reply();
956 957
 }
... ...
@@ -1203,7 +1204,7 @@ int t_is_local(struct sip_msg* p_msg)
1203 1204
 	return -1;
1204 1205
     }
1205 1206
     
1206
-    return t->local;
1207
+    return is_local(t);
1207 1208
 }
1208 1209
 
1209 1210
 /* lookup a transaction by callid and cseq, parameters are pure
... ...
@@ -37,6 +37,7 @@
37 37
  *             avoid late ACK sending (jiri)
38 38
  * 2003-10-02  added via_builder set host/port support (andrei)
39 39
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
40
+ * 2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
40 41
  */
41 42
 
42 43
 #include "defs.h"
... ...
@@ -101,7 +102,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
101 102
 		goto error;
102 103
 	branch_str.s=branch_buf;
103 104
 	branch_str.len=branch_len;
104
-	set_hostport(&hp, (Trans->local)?0:(Trans->uas.request));
105
+	set_hostport(&hp, (is_local(Trans))?0:(Trans->uas.request));
105 106
 	via=via_builder(&via_len, Trans->uac[branch].request.dst.send_sock,
106 107
 		&branch_str, 0, Trans->uac[branch].request.dst.proto, &hp );
107 108
 	if (!via)
... ...
@@ -117,7 +118,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
117 118
 
118 119
 
119 120
 	/* copy'n'paste Route headers */
120
-	if (!Trans->local) {
121
+	if (!is_local(Trans)) {
121 122
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
122 123
 			 if (hdr->type==HDR_ROUTE)
123 124
 				*len+=hdr->len;
... ...
@@ -156,7 +157,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
156 157
 	append_mem_block( p, method, method_len );
157 158
 	append_mem_block( p, CRLF, CRLF_LEN );
158 159
 
159
-	if (!Trans->local)  {
160
+	if (!is_local(Trans))  {
160 161
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
161 162
 			if(hdr->type==HDR_ROUTE) {
162 163
 				append_mem_block(p, hdr->name.s, hdr->len );
... ...
@@ -58,6 +58,7 @@
58 58
  *  2003-11-05  flag context updated from failure/reply handlers back
59 59
  *              to transaction context (jiri)
60 60
  *  2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
61
+ *  2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
61 62
  */
62 63
 
63 64
 
... ...
@@ -287,7 +288,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
287 288
 	{
288 289
 		DBG("DEBUG: t_reply: response building failed\n");
289 290
 		/* determine if there are some branches to be cancelled */
290
-		if (trans->is_invite) {
291
+		if ( is_invite(trans) ) {
291 292
 			if (lock) LOCK_REPLIES( trans );
292 293
 			which_cancel(trans, &cancel_bitmap );
293 294
 			if (lock) UNLOCK_REPLIES( trans );
... ...
@@ -298,7 +299,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
298 299
 
299 300
 	cancel_bitmap=0;
300 301
 	if (lock) LOCK_REPLIES( trans );
301
-	if (trans->is_invite) which_cancel(trans, &cancel_bitmap );
302
+	if ( is_invite(trans) ) which_cancel(trans, &cancel_bitmap );
302 303
 	if (trans->uas.status>=200) {
303 304
 		LOG( L_ERR, "ERROR: t_reply: can't generate %d reply"
304 305
 			" 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,
332 333
 	/* do UAC cleanup procedures in case we generated
333 334
 	   a final answer whereas there are pending UACs */
334 335
 	if (code>=200) {
335
-		if (trans->local) {
336
+		if ( is_local(trans) ) {
336 337
 			DBG("DEBUG: local transaction completed from _reply\n");
337 338
 			if ( has_tran_tmcbs(trans, TMCB_LOCAL_COMPLETED) )
338 339
 				run_trans_callbacks( TMCB_LOCAL_COMPLETED, trans,
... ...
@@ -344,7 +345,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
344 345
 		}
345 346
 
346 347
 		cleanup_uac_timers( trans );
347
-		if (trans->is_invite) cancel_uacs( trans, cancel_bitmap );
348
+		if (is_invite(trans)) cancel_uacs( trans, cancel_bitmap );
348 349
 		set_final_timer(  trans );
349 350
 	}
350 351
 
... ...
@@ -370,7 +371,7 @@ error2:
370 371
 error:
371 372
 	/* do UAC cleanup */
372 373
 	cleanup_uac_timers( trans );
373
-	if (trans->is_invite) cancel_uacs( trans, cancel_bitmap );
374
+	if ( is_invite(trans) ) cancel_uacs( trans, cancel_bitmap );
374 375
 	/* we did not succeed -- put the transaction on wait */
375 376
 	put_on_wait(trans);
376 377
 	return -1;
... ...
@@ -605,7 +606,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
605 606
 	   out
606 607
 	*/
607 608
 	DBG("->>>>>>>>> T_code=%d, new_code=%d\n",Trans->uas.status,new_code);
608
-	inv_through=new_code>=200 && new_code<300 && Trans->is_invite;
609
+	inv_through=new_code>=200 && new_code<300 && is_invite(Trans);
609 610
 	/* if final response sent out, allow only INVITE 2xx  */
610 611
 	if ( Trans->uas.status >= 200 ) {
611 612
 		if (inv_through) {
... ...
@@ -784,7 +785,7 @@ int t_reply_unsafe( struct cell *t, struct sip_msg* p_msg, unsigned int code,
784 785
 
785 786
 void set_final_timer( /* struct s_table *h_table, */ struct cell *t )
786 787
 {
787
-	if ( !t->local && t->uas.request->REQ_METHOD==METHOD_INVITE ) {
788
+	if ( !is_local(t) && t->uas.request->REQ_METHOD==METHOD_INVITE ) {
788 789
 		/* crank timers for negative replies */
789 790
 		if (t->uas.status>=300) {
790 791
 			start_retr(&t->uas.response);
... ...
@@ -962,7 +963,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
962 963
 		t->uas.status = relayed_code;
963 964
 		t->relaied_reply_branch = relay;
964 965
 
965
-		if (t->is_invite && relayed_msg!=FAKED_REPLY
966
+		if (is_invite(t) && relayed_msg!=FAKED_REPLY
966 967
 		&& relayed_code>=200 && relayed_code < 300
967 968
 		&& has_tran_tmcbs( t, TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) ) {
968 969
 			totag_retr=update_totag_set(t, relayed_msg);
... ...
@@ -997,10 +998,9 @@ error02:
997 998
 error01:
998 999
 	t_reply_unsafe( t, t->uas.request, 500, "Reply processing error" );
999 1000
 	UNLOCK_REPLIES(t);
1000
-	if (t->is_invite) cancel_uacs( t, *cancel_bitmap );
1001
+	if (is_invite(t)) cancel_uacs( t, *cancel_bitmap );
1001 1002
 	/* a serious error occured -- attempt to send an error reply;
1002
-	   it will take care of clean-ups 
1003
-	*/
1003
+	   it will take care of clean-ups  */
1004 1004
 
1005 1005
 	/* failure */
1006 1006
 	return RPS_ERROR;
... ...
@@ -1048,7 +1048,7 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1048 1048
 		}
1049 1049
 		t->uas.status = winning_code;
1050 1050
 		update_reply_stats( winning_code );
1051
-		if (t->is_invite && winning_msg!=FAKED_REPLY
1051
+		if (is_invite(t) && winning_msg!=FAKED_REPLY
1052 1052
 		&& winning_code>=200 && winning_code <300
1053 1053
 		&& has_tran_tmcbs(t,TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) )  {
1054 1054
 			totag_retr=update_totag_set(t, winning_msg);
... ...
@@ -1113,13 +1113,13 @@ int reply_received( struct sip_msg  *p_msg )
1113 1113
 	DBG("DEBUG: t_on_reply: org. status uas=%d, "
1114 1114
 		"uac[%d]=%d local=%d is_invite=%d)\n",
1115 1115
 		t->uas.status, branch, uac->last_received, 
1116
-		t->local, t->is_invite);
1116
+		is_local(t), is_invite(t));
1117 1117
 
1118 1118
 	/* it's a cancel ... ? */
1119 1119
 	if (get_cseq(p_msg)->method.len==CANCEL_LEN 
1120 1120
 		&& memcmp( get_cseq(p_msg)->method.s, CANCEL, CANCEL_LEN)==0
1121 1121
 		/* .. which is not e2e ? ... */
1122
-		&& t->is_invite ) {
1122
+		&& is_invite(t) ) {
1123 1123
 			/* ... then just stop timers */
1124 1124
 			reset_timer( &uac->local_cancel.retr_timer);
1125 1125
 			if ( msg_status >= 200 )
... ...
@@ -1135,12 +1135,10 @@ int reply_received( struct sip_msg  *p_msg )
1135 1135
 	/* stop final response timer only if I got a final response */
1136 1136
 	if ( msg_status >= 200 )
1137 1137
 		reset_timer( &uac->request.fr_timer);
1138
-        
1139
-        /* acknowledge negative INVITE replies (do it before detailed
1140
-           on_reply processing, which may take very long, like if it
1141
-           is attempted to establish a TCP connection to a fail-over dst
1142
-        */
1143
-	if (t->is_invite && (msg_status>=300 || (t->local && msg_status>=200))) {
1138
+		/* acknowledge negative INVITE replies (do it before detailed
1139
+		 * on_reply processing, which may take very long, like if it
1140
+		 * is attempted to establish a TCP connection to a fail-over dst */
1141
+	if (is_invite(t) && (msg_status>=300 || (is_local(t) && msg_status>=200))){
1144 1142
 		ack = build_ack( p_msg, t, branch, &ack_len);
1145 1143
 		if (ack) {
1146 1144
 			SEND_PR_BUFFER( &uac->request, ack, ack_len );
... ...
@@ -1161,7 +1159,7 @@ int reply_received( struct sip_msg  *p_msg )
1161 1159
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
1162 1160
 	}
1163 1161
 	LOCK_REPLIES( t );
1164
-	if (t->local) {
1162
+	if ( is_local(t) ) {
1165 1163
 		reply_status=local_reply( t, p_msg, branch, msg_status, &cancel_bitmap );
1166 1164
 	} else {
1167 1165
 		reply_status=relay_reply( t, p_msg, branch, msg_status, 
... ...
@@ -1177,14 +1175,14 @@ int reply_received( struct sip_msg  *p_msg )
1177 1175
 		   be still pending branches ...
1178 1176
 		*/
1179 1177
 		cleanup_uac_timers( t );	
1180
-		if (t->is_invite) cancel_uacs( t, cancel_bitmap );
1178
+		if (is_invite(t)) cancel_uacs( t, cancel_bitmap );
1181 1179
 		/* FR for negative INVITES, WAIT anything else */
1182 1180
 		set_final_timer(  t );
1183 1181
 	} 
1184 1182
 
1185 1183
 	/* update FR/RETR timers on provisional replies */
1186 1184
 	if (msg_status<200) { /* provisional now */
1187
-		if (t->is_invite) { 
1185
+		if (is_invite(t)) {
1188 1186
 			/* invite: change FR to longer FR_INV, do not
1189 1187
 			   attempt to restart retransmission any more
1190 1188
 			*/
... ...
@@ -96,6 +96,8 @@
96 96
  * History:
97 97
  * --------
98 98
  *  2003-06-27  timers are not unlinked if timerlist is 0 (andrei)
99
+ *  2004-02-13  t->is_invite, t->local, t->noisy_ctimer replaced;
100
+ *              timer_link.payload removed (bogdan)
99 101
  */
100 102
 
101 103
 #include "defs.h"
... ...
@@ -239,10 +241,10 @@ static void fake_reply(struct cell *t, int branch, int code )
239 241
 	short do_cancel_branch;
240 242
 	enum rps reply_status;
241 243
 
242
-	do_cancel_branch=t->is_invite && should_cancel_branch(t, branch);
244
+	do_cancel_branch = is_invite(t) && should_cancel_branch(t, branch);
243 245
 
244 246
 	cancel_bitmap=do_cancel_branch ? 1<<branch : 0;
245
-	if (t->local) {
247
+	if ( is_local(t) ) {
246 248
 		reply_status=local_reply( t, FAKED_REPLY, branch, 
247 249
 			code, &cancel_bitmap );
248 250
 	} else {
... ...
@@ -273,12 +275,12 @@ static void fake_reply(struct cell *t, int branch, int code )
273 275
 
274 276
 
275 277
 
276
-inline static void retransmission_handler( void *attr)
278
+inline static void retransmission_handler( struct timer_link *retr_tl )
277 279
 {
278 280
 	struct retr_buf* r_buf ;
279 281
 	enum lists id;
280 282
 
281
-	r_buf = (struct retr_buf*)attr;
283
+	r_buf = get_retr_timer_payload(retr_tl);
282 284
 #ifdef EXTRA_DEBUG
283 285
 	if (r_buf->my_T->damocles) {
284 286
 		LOG( L_ERR, "ERROR: transaction %p scheduled for deletion and"
... ...
@@ -290,7 +292,7 @@ inline static void retransmission_handler( void *attr)
290 292
 	/*the transaction is already removed from RETRANSMISSION_LIST by timer*/
291 293
 	/* retransmision */
292 294
 	if ( r_buf->activ_type==TYPE_LOCAL_CANCEL 
293
-		|| r_buf->activ_type==0 ) {
295
+		|| r_buf->activ_type==TYPE_REQUEST ) {
294 296
 			DBG("DEBUG: retransmission_handler : "
295 297
 				"request resending (t=%p, %.9s ... )\n", 
296 298
 				r_buf->my_T, r_buf->buffer);
... ...
@@ -309,9 +311,8 @@ inline static void retransmission_handler( void *attr)
309 311
 	id = r_buf->retr_list;
310 312
 	r_buf->retr_list = id < RT_T2 ? id + 1 : RT_T2;
311 313
 	
312
-	r_buf->retr_timer.timer_list= NULL; /* set to NULL so that set_timer
313
-										   will work */
314
-	set_timer(&(r_buf->retr_timer),id < RT_T2 ? id + 1 : RT_T2 );
314
+	retr_tl->timer_list= NULL; /* set to NULL so that set_timer will work */
315
+	set_timer( retr_tl, id < RT_T2 ? id + 1 : RT_T2 );
315 316
 
316 317
 	DBG("DEBUG: retransmission_handler : done\n");
317 318
 }
... ...
@@ -319,18 +320,18 @@ inline static void retransmission_handler( void *attr)
319 320
 
320 321
 
321 322
 
322
-inline static void final_response_handler( void *attr)
323
+inline static void final_response_handler( struct timer_link *fr_tl )
323 324
 {
324 325
 	int silent;
325 326
 	struct retr_buf* r_buf;
326 327
 	struct cell *t;
327 328
 
328
-	r_buf = (struct retr_buf*)attr;
329
-	if (r_buf==0){
329
+	if (fr_tl==0){
330 330
 		/* or BUG?, ignoring it for now */
331 331
 		LOG(L_CRIT, "ERROR: final_response_handler(0) called\n");
332 332
 		return;
333 333
 	}
334
+	r_buf = get_fr_timer_payload(fr_tl);
334 335
 	t=r_buf->my_T;
335 336
 
336 337
 #	ifdef EXTRA_DEBUG
... ...
@@ -374,22 +375,22 @@ inline static void final_response_handler( void *attr)
374 375
 	   world */
375 376
 	silent=
376 377
 		/* not for UACs */
377
-		!t->local
378
+		!is_local(t)
378 379
 		/* invites only */
379
-		&& t->is_invite
380
+		&& is_invite(t)
380 381
 		/* parallel forking does not allow silent state discarding */
381 382
 		&& t->nr_of_outgoings==1
382 383
 		/* on_negativ reply handler not installed -- serial forking 
383 384
 		 * could occur otherwise */
384 385
 		&& t->on_negative==0
385 386
 		/* the same for FAILURE callbacks */
386
-		&& (t->tmcb_hl.reg_types&(TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE))==0
387
+		&& !has_tran_tmcbs( t, TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE) 
387 388
 		/* something received -- we will not be silent on error */
388 389
 		&& t->uac[r_buf->branch].last_received>0
389 390
 		/* don't go silent if disallowed globally ... */
390 391
 		&& noisy_ctimer==0
391 392
 		/* ... or for this particular transaction */
392
-		&& t->noisy_ctimer==0;
393
+		&& has_noisy_ctimer(t);
393 394
 	if (silent) {
394 395
 		UNLOCK_REPLIES(t);
395 396
 		DBG("DEBUG: FR_handler: transaction silently dropped (%p)\n",t);
... ...
@@ -403,6 +404,8 @@ inline static void final_response_handler( void *attr)
403 404
 	DBG("DEBUG: final_response_handler : done\n");
404 405
 }
405 406
 
407
+
408
+
406 409
 void cleanup_localcancel_timers( struct cell *t )
407 410
 {
408 411
 	int i;
... ...
@@ -413,10 +416,11 @@ void cleanup_localcancel_timers( struct cell *t )
413 416
 }
414 417
 
415 418
 
416
-inline static void wait_handler( void *attr)
419
+inline static void wait_handler( struct timer_link *wait_tl )
417 420
 {
418
-	struct cell *p_cell = (struct cell*)attr;
421
+	struct cell *p_cell;
419 422
 
423
+	p_cell = get_wait_timer_payload( wait_tl );
420 424
 #ifdef EXTRA_DEBUG
421 425
 	if (p_cell->damocles) {
422 426
 		LOG( L_ERR, "ERROR: transaction %p scheduled for deletion and"
... ...
@@ -427,7 +431,7 @@ inline static void wait_handler( void *attr)
427 431
 #endif
428 432
 
429 433
 	/* stop cancel timers if any running */
430
-	if (p_cell->is_invite) cleanup_localcancel_timers( p_cell );
434
+	if ( is_invite(p_cell) ) cleanup_localcancel_timers( p_cell );
431 435
 
432 436
 	/* the transaction is already removed from WT_LIST by the timer */
433 437
 	/* remove the cell from the hash table */
... ...
@@ -445,11 +449,11 @@ inline static void wait_handler( void *attr)
445 449
 
446 450
 
447 451
 
448
-
449
-inline static void delete_handler( void *attr)
452
+inline static void delete_handler( struct timer_link *dele_tl )
450 453
 {
451
-	struct cell *p_cell = (struct cell*)attr;
454
+	struct cell *p_cell;
452 455
 
456
+	p_cell = get_dele_timer_payload( dele_tl );
453 457
 	DBG("DEBUG: delete_handler : removing %p \n", p_cell );
454 458
 #ifdef EXTRA_DEBUG
455 459
 	if (p_cell->damocles==0) {
... ...
@@ -498,7 +502,7 @@ void unlink_timer_lists()
498 502
 	   (they are no more accessible from enrys) */
499 503
 	while (tl!=end) {
500 504
 		tmp=tl->next_tl;
501
-		free_cell((struct cell*)tl->payload);
505
+		free_cell( get_dele_timer_payload(tl) );
502 506
 		tl=tmp;
503 507
 	}
504 508
 	
... ...
@@ -864,7 +868,7 @@ static void unlink_timers( struct cell *t )
864 868
 		DBG("DEBUG: timer routine:%d,tl=%p next=%p\n",\
865 869
 			id,(_tl),tmp_tl);\
866 870
 		if ((_tl)->time_out>TIMER_DELETED) \
867
-			(_handler)( (_tl)->payload );\
871
+			(_handler)( _tl );\
868 872
 		(_tl) = tmp_tl;\
869 873
 	}
870 874
 
... ...
@@ -877,10 +881,6 @@ void timer_routine(unsigned int ticks , void * attr)
877 881
 	struct timer_link *tl, *tmp_tl;
878 882
 	int                id;
879 883
 
880
-#ifdef BOGDAN_TRIFLE
881
-	DBG(" %d \n",ticks);
882
-#endif
883
-
884 884
 	for( id=0 ; id<NR_OF_TIMER_LISTS ; id++ )
885 885
 	{
886 886
 		/* to waste as little time in lock as possible, detach list
... ...
@@ -28,6 +28,7 @@
28 28
  * History:
29 29
  * --------
30 30
  *  2003-09-12  timer_link.tg exists only if EXTRA_DEBUG (andrei)
31
+ *  2004-02-13  timer_link.payload removed (bogdan)
31 32
  */
32 33
 
33 34
 
... ...
@@ -62,11 +63,10 @@ enum lists
62 63
    links to neighbours and timer value */
63 64
 typedef struct timer_link
64 65
 {
65
-	struct timer_link *next_tl;
66
-	struct timer_link *prev_tl;
67
-	volatile unsigned int       time_out;
68
-	void              *payload;
69
-	struct timer      *timer_list;
66
+	struct timer_link     *next_tl;
67
+	struct timer_link     *prev_tl;
68
+	volatile unsigned int  time_out;
69
+	struct timer          *timer_list;
70 70
 #ifdef EXTRA_DEBUG
71 71
 	enum timer_groups  tg;
72 72
 #endif
... ...
@@ -452,7 +452,7 @@ static int script_init( struct sip_msg *foo, void *bar)
452 452
 
453 453
 static int mod_init(void)
454 454
 {
455
-	DBG( "TM - initializing...\n");
455
+	DBG( "TM - (size of cell=%d) initializing...\n",sizeof(struct cell));
456 456
 	/* checking if we have sufficient bitmap capacity for given
457 457
 	   maximum number of  branches */
458 458
 	if (MAX_BRANCHES+1>31) {
... ...
@@ -48,6 +48,7 @@
48 48
  *  2003-12-03  completion filed removed from transaction and uac callbacks
49 49
  *              merged in transaction callbacks as LOCAL_COMPLETED (bogdan)
50 50
  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
51
+ *  2004-02-13  t->is_invite, t->local, t->noisy_ctimer replaced (bogdan)
51 52
  */
52 53
 
53 54
 #include <string.h>
... ...
@@ -202,11 +203,11 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
202 203
 		goto error2;
203 204
 	}
204 205
 
205
-	new_cell->is_invite =
206
-		method->len==INVITE_LEN && memcmp(method->s, INVITE, INVITE_LEN)==0;
207
-	new_cell->local= 1;
206
+	if (method->len==INVITE_LEN && memcmp(method->s, INVITE, INVITE_LEN)==0)
207
+		new_cell->flags |= T_IS_INVITE_FLAG;
208
+	new_cell->flags |= T_IS_LOCAL_FLAG;
208 209
 	set_kr(REQ_FWDED);
209
-	
210
+
210 211
 	request = &new_cell->uac[0].request;
211 212
 	request->dst.to = to_su;
212 213
 	request->dst.send_sock = send_sock;