Skip to content

Instantly share code, notes, and snippets.

@bogdan-iancu
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan-iancu/0d21b8a56d67a33272db to your computer and use it in GitHub Desktop.
Save bogdan-iancu/0d21b8a56d67a33272db to your computer and use it in GitHub Desktop.
diff --git a/modules/tm/h_table.h b/modules/tm/h_table.h
index 64f052e..534c411 100644
--- a/modules/tm/h_table.h
+++ b/modules/tm/h_table.h
@@ -153,12 +153,14 @@ typedef struct ua_client
str extra_headers;
/* the body in the request sent out from a dlg structure */
str body;
- /* number of RR headers that were locally added for this branch */
- unsigned int added_rr;
/* if we store a reply (branch picking), this is where it is */
struct sip_msg *reply;
+ /* the highest reply code received on this branch */
+ short highest_received;
/* if we don't store, we at least want to know the status */
short last_received;
+ /* number of RR headers that were locally added for this branch */
+ unsigned short added_rr;
/* UAC specific flags */
short flags;
/* script flags, specific to this branch */
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 08107fb..1157529 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -970,6 +970,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
if (new_code >=300 ) {
Trans->uac[branch].last_received=new_code;
+ Trans->uac[branch].highest_received=new_code;
/* also append the current reply to the transaction to
* make it available in failure routes - a kind of "fake"
* save of the final reply per branch */
@@ -1071,6 +1072,8 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
if (new_code>=100) {
/* 1xx and 2xx except 100 will be relayed */
Trans->uac[branch].last_received=new_code;
+ if (new_code > Trans->uac[branch].highest_received)
+ Trans->uac[branch].highest_received = new_code;
*should_store=0;
*should_relay= new_code==100? -1 : branch;
if (new_code>=200 ) {
@@ -1487,7 +1490,6 @@ error:
int reply_received( struct sip_msg *p_msg )
{
int msg_status;
- int last_uac_status;
int branch;
int reply_status;
utime_t timer;
@@ -1514,7 +1516,6 @@ int reply_received( struct sip_msg *p_msg )
LM_DBG("org. status uas=%d, uac[%d]=%d local=%d is_invite=%d)\n",
t->uas.status, branch, uac->last_received,
is_local(t), is_invite(t));
- last_uac_status=uac->last_received;
if_update_stat( tm_enable_stats, tm_rcv_rpls , 1);
/* it's a cancel which is not e2e ? */
@@ -1638,8 +1639,8 @@ int reply_received( struct sip_msg *p_msg )
/* update FR/RETR timers on provisional replies */
if (msg_status < 200 && (restart_fr_on_each_reply ||
- ((last_uac_status<msg_status) &&
- ((msg_status >= 180) || (last_uac_status == 0)))
+ ((uac->highest_received<msg_status) &&
+ ((msg_status >= 180) || (uac->highest_received == 0)))
) ) { /* provisional now */
if (is_invite(t)) {
/* invite: change FR to longer FR_INV, do not
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment