Browse code

change: to-tags no more compared in ACK lookups -- that eliminates an unlikely race conditions (reading transactional to-tag on ACK lookup whereas writing a new to tag from 200/OK) and helps UACs who screw up to-tags

Jiri Kuthan authored on 18/10/2002 02:32:14
Showing 5 changed files
... ...
@@ -256,31 +256,29 @@ Note the the request write must be atomic, otherwise the request
256 256
 might get intermixes with writes from other writers.
257 257
 You can easily use it via Unix command-line tools, see the following
258 258
 example:
259
-[jiri@bat jiri]$ cat > /tmp/fifo
260
-:t_uac:xxx
261
-MESSAGE
262
-sip:mrx@iptel.org
263
-header:value
264
-foo:bar
265
-bznk:hjhjk
266
-p_header: p_value
267 259
 
268
-body body body
269
-yet body
270
-end of body
260
+cat test/transaction.fifo > /tmp/ser_fifo
261
+--
271 262
 
263
+Defines
264
+-------
265
+- TOTAG enables matching of acknowledgemnts including to-tags;
266
+  it is disabled by default for two reasons:
267
+  a) it eliminates an unlikely race condition in which
268
+     transaction's to-tag is being rewritten by a 200 OK
269
+     whereas an ACK is being looked up by to-tag
270
+  b) it makes UACs happy who set wrong to-tags
272 271
 
272
+  It should not make a difference, as there may be only one
273
+  negative reply sent upstream and 200/ACKs are not matched
274
+  as they consititute another transaction. It will make no
275
+  difference at all when the new magic cookie matching is
276
+  enabled.
273 277
 
274
-or use an example file and call cat test/transaction.fifo > /tmp/fifo
275 278
 
276 279
 
277 280
 Known Issues
278 281
 -----------
279
-- need to revisit profiling again
280
-- review whether there is not potential for to-tag
281
-  rewriting and ACK matching
282 282
 - we don't have authentication merging on forking
283 283
 - branch tid is not used yet
284 284
 - local ACK/CANCELs copy'n'pastes Route and ignores deleted
... ...
@@ -90,8 +90,10 @@ void free_cell( struct cell* dead_cell )
90 90
 		sip_msg_free_unsafe( dead_cell->uas.request );
91 91
 	if ( dead_cell->uas.response.buffer )
92 92
 		shm_free_unsafe( dead_cell->uas.response.buffer );
93
+#ifdef TOTAG
93 94
 	if (dead_cell->uas.to_tag.s)
94 95
 		shm_free_unsafe(dead_cell->uas.to_tag.s);
96
+#endif
95 97
 
96 98
 	/* completion callback */
97 99
 	if (dead_cell->cbp) shm_free_unsafe(dead_cell->cbp);
... ...
@@ -106,7 +106,9 @@ typedef struct ua_server
106 106
 	struct sip_msg   *request;
107 107
 	struct retr_buf  response;
108 108
 	unsigned int     status;
109
+#ifdef TOTAG
109 110
 	str              to_tag;
111
+#endif
110 112
 	unsigned int     isACKed;
111 113
 }ua_server_type;
112 114
 
... ...
@@ -191,9 +191,11 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
191 191
 			/* To only the uri and ... */
192 192
 			if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
193 193
 				continue;
194
+#ifdef TOTAG
194 195
 			/* ... its to-tag compared to reply's tag */
195 196
 			if (p_cell->uas.to_tag.len!=get_to(p_msg)->tag_value.len)
196 197
 				continue;
198
+#endif
197 199
 
198 200
 			/* we first skip r-uri and Via and proceed with
199 201
 			   content of other header-fields */
... ...
@@ -205,12 +207,14 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
205 207
 			if (!EQ_STR(from)) continue;
206 208
 			if (memcmp(get_to(t_msg)->uri.s, get_to(p_msg)->uri.s,
207 209
 				get_to(t_msg)->uri.len)!=0) continue;
210
+#ifdef TOTAG
208 211
 			if (
209 212
 #ifdef _BUG
210 213
 				p_cell->uas.to_tag.len!=0 /* to-tags empty */ || 
211 214
 #endif
212 215
 				memcmp(p_cell->uas.to_tag.s, get_to(p_msg)->tag_value.s,
213 216
 				p_cell->uas.to_tag.len)!=0) continue;
217
+#endif
214 218
 	
215 219
 			/* ok, now only r-uri or via can mismatch; they must match
216 220
 			   for non-2xx; if it is a 2xx, we don't try to match
... ...
@@ -486,7 +486,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
486 486
 	unsigned int res_len;
487 487
 	int relayed_code;
488 488
 	struct sip_msg *relayed_msg;
489
+#ifdef TOTAG
489 490
 	str	to_tag;
491
+#endif
490 492
 	enum rps reply_status;
491 493
 	/* retransmission structure of outbound reply and request */
492 494
 	struct retr_buf *uas_rb;
... ...
@@ -569,6 +571,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
569 571
 		}
570 572
 		uas_rb->buffer_len = res_len;
571 573
 		memcpy( uas_rb->buffer, buf, res_len );
574
+#ifdef TOTAG
572 575
 		/* to tag now */
573 576
 		if (relayed_code>=300 && t->is_invite) {
574 577
 			if (relayed_msg!=FAKED_REPLY) {
... ...
@@ -587,6 +590,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
587 590
 				t->uas.to_tag.len=0;
588 591
 			}
589 592
 		}
593
+#endif
590 594
 
591 595
 		/* update the status ... */
592 596
 		t->uas.status = relayed_code;
... ...
@@ -607,9 +611,11 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
607 611
 	/* success */
608 612
 	return reply_status;
609 613
 
614
+#ifdef TOTAG
610 615
 error04:
611 616
 	shm_free( uas_rb->buffer );
612 617
 	uas_rb->buffer=0;
618
+#endif
613 619
 error03:
614 620
 	pkg_free( buf );
615 621
 error02: