Browse code

cancel bug fixes

Jiri Kuthan authored on 17/08/2002 02:45:50
Showing 4 changed files
... ...
@@ -51,4 +51,10 @@
51 51
 #define MAX_HEADER	1024
52 52
 #define MAX_BODY	1024
53 53
 #define MAX_DST	512
54
+
55
+/* messages generated by server */
56
+#define CANCELLING "cancelling"
57
+#define CANCEL_DONE "ok -- no more pending branches"
58
+#define CANCELLED "Request cancelled"
59
+
54 60
 #endif
... ...
@@ -19,6 +19,7 @@
19 19
 #include "t_lookup.h"
20 20
 #include "t_fwd.h"
21 21
 #include "fix_lumps.h"
22
+#include "config.h"
22 23
 
23 24
 
24 25
 #ifdef _OBSOLETED
... ...
@@ -243,6 +244,9 @@ void e2e_cancel( struct sip_msg *cancel_msg,
243 244
 	backup_uri=cancel_msg->new_uri;
244 245
 	/* determine which branches to cancel ... */
245 246
 	which_cancel( t_invite, &cancel_bm );
247
+	t_cancel->nr_of_outgoings=t_invite->nr_of_outgoings;
248
+	/* fix label -- it must be same for reply matching */
249
+	t_cancel->label=t_invite->label;
246 250
 	/* ... and install CANCEL UACs */
247 251
 	for (i=0; i<t_invite->nr_of_outgoings; i++)
248 252
 		if (cancel_bm & (1<<i)) {
... ...
@@ -250,8 +254,6 @@ void e2e_cancel( struct sip_msg *cancel_msg,
250 254
 			if (ret<0) cancel_bm &= ~(1<<i);
251 255
 			if (ret<lowest_error) lowest_error=ret;
252 256
 		}
253
-	t_cancel->nr_of_outgoings=t_invite->nr_of_outgoings;
254
-	t_cancel->label=t_invite->label;
255 257
 	cancel_msg->new_uri=backup_uri;
256 258
 
257 259
 	/* send them out */
... ...
@@ -276,14 +278,21 @@ void e2e_cancel( struct sip_msg *cancel_msg,
276 278
 	*/
277 279
 	} else if (cancel_bm) {
278 280
 		DBG("DEBUG: e2e_cancel: e2e cancel proceeding\n");
279
-		t_reply( t_cancel, cancel_msg, 100, "trying to cancel" );
281
+		t_reply( t_cancel, cancel_msg, 200, CANCELLING );
280 282
 	/* if the transaction exists, but there is no more pending
281 283
 	   branch, tell usptream we're done
282 284
 	*/
283 285
 	} else {
284 286
 		DBG("DEBUG: e2e_cancel: e2e cancel -- no more pending branches\n");
285
-		t_reply( t_cancel, cancel_msg, 200, "ok, no more pending branches" );
287
+		t_reply( t_cancel, cancel_msg, 200, CANCEL_DONE );
286 288
 	}
289
+	/* we could await downstream UAS's 487 replies; however,
290
+	   if some of the branches does not do that, we could wait
291
+	   long time and annoy upstream UAC which wants to see 
292
+	   a result of CANCEL quickly
293
+	*/
294
+	DBG("DEBUG: e2e_cancel: sending 487\n");
295
+	t_reply(t_invite, t_invite->uas.request, 487, CANCELLED );
287 296
 }
288 297
 
289 298
 
... ...
@@ -292,16 +292,18 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table ,
292 292
 			continue;
293 293
 
294 294
 		/* found */
295
-		REF( p_cell );
296
-		UNLOCK_HASH(hash_index);
297 295
 		DBG("DEBUG: t_lookupOriginalT: canceled transaction"
298 296
 			" found (%p)! \n",p_cell );
297
+		REF_UNSAFE( p_cell );
298
+		UNLOCK_HASH(hash_index);
299
+		DBG("DEBUG: t_lookupOriginalT completed\n");
299 300
 		return p_cell;
300 301
 	}
301 302
 
302 303
 	/* no transaction found */
303
-	UNLOCK_HASH(hash_index);
304 304
 	DBG("DEBUG: t_lookupOriginalT: no CANCEL maching found! \n" );
305
+	UNLOCK_HASH(hash_index);
306
+	DBG("DEBUG: t_lookupOriginalT completed\n");
305 307
 	return 0;
306 308
 }
307 309
 
... ...
@@ -430,7 +432,12 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
430 432
 			&& memcmp( cseq_method.s, req_method.s, cseq_method.len )==0)
431 433
 			/* or it is a local cancel */
432 434
 			|| (is_cancel && p_cell->is_invite 
433
-				&& p_cell->uac[branch_id].local_cancel.buffer )))
435
+				/* commented out -- should_cancel_branch set it to
436
+				   BUSY_BUFFER to avoid collisions with repliesl;
437
+				   thus, we test here by bbuffer size
438
+				*/
439
+				/* && p_cell->uac[branch_id].local_cancel.buffer ))) */
440
+				&& p_cell->uac[branch_id].local_cancel.buffer_len ))) 
434 441
 			continue;
435 442
 
436 443
 
... ...
@@ -527,8 +527,10 @@ int t_on_reply( struct sip_msg  *p_msg )
527 527
 	msg_status=p_msg->REPLY_STATUS;
528 528
 
529 529
 	uac=&t->uac[branch];
530
-	DBG("DEBUG: t_on_reply: org. status uas=%d, uac[%d]=%d local=%d)\n",
531
-		t->uas.status, branch, uac->last_received, t->local);
530
+	DBG("DEBUG: t_on_reply: org. status uas=%d, "
531
+		"uac[%d]=%d local=%d is_invite=%d)\n",
532
+		t->uas.status, branch, uac->last_received, 
533
+		t->local, t->is_invite);
532 534
 
533 535
 	/* it's a cancel ... ? */
534 536
 	if (get_cseq(p_msg)->method.len==CANCEL_LEN