Browse code

acc: use r-uri winning branch even for local generated replies

- it was only for received and relayed replies
- reported by Kelvin Chua

(cherry picked from commit 81b9c83b2fa3bd32d502a1ae9014cc7d6747e710)

Daniel-Constantin Mierla authored on 19/12/2013 20:15:12
Showing 1 changed files
... ...
@@ -344,11 +344,20 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
344 344
 {
345 345
 	str new_uri_bk = {0, 0};
346 346
 	int flags_to_reset = 0;
347
+	int br = -1;
347 348
 
348
-	/* set as new_uri the last branch */
349
+	/* get winning branch index, if set */
349 350
 	if (t->relayed_reply_branch>=0) {
351
+		br = t->relayed_reply_branch;
352
+	} else {
353
+		if(code>=300) {
354
+			br = tmb.t_get_picked_branch();
355
+		}
356
+	}
357
+	/* set as new_uri the one from selected branch */
358
+	if (br>=0) {
350 359
 		new_uri_bk = req->new_uri;
351
-		req->new_uri = t->uac[t->relayed_reply_branch].uri;
360
+		req->new_uri = t->uac[br].uri;
352 361
 		req->parsed_uri_ok = 0;
353 362
 	} else {
354 363
 		new_uri_bk.len = -1;
... ...
@@ -416,6 +425,7 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
416 416
 											struct sip_msg *reply, int code)
417 417
 {
418 418
 	str new_uri_bk;
419
+	int br = -1;
419 420
 
420 421
 	/* acc_onreply is bound to TMCB_REPLY which may be called
421 422
 	   from _reply, like when FR hits; we should not miss this
... ...
@@ -426,10 +436,19 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
426 426
 	if (!should_acc_reply(req, reply, code))
427 427
 		return;
428 428
 
429
-	/* for reply processing, set as new_uri the winning branch */
429
+	/* get winning branch index, if set */
430 430
 	if (t->relayed_reply_branch>=0) {
431
+		br = t->relayed_reply_branch;
432
+	} else {
433
+		if(code>=300) {
434
+			br = tmb.t_get_picked_branch();
435
+		}
436
+	}
437
+
438
+	/* for reply processing, set as new_uri the one from selected branch */
439
+	if (br>=0) {
431 440
 		new_uri_bk = req->new_uri;
432
-		req->new_uri = t->uac[t->relayed_reply_branch].uri;
441
+		req->new_uri = t->uac[br].uri;
433 442
 		req->parsed_uri_ok = 0;
434 443
 	} else {
435 444
 		new_uri_bk.len = -1;