Review Board 1.7.16


Guard against retransmitting a BYE forever

Review Request #1077 - Created Jan. 18, 2011 and submitted

Terry Wilson
1.4
Reviewers
asterisk-dev
dvossel
Asterisk
In the case of an attended transfer (A calls B, A atxfers to C) where A becomes unreachable before replying to Asterisk's BYE, Asterisk can sometimes retransmit the BYE indefinitely. This is because __sip_autodestruct tests p->refer && !ast_test_flag(&p->flags[0], SIP_ALREADYGONE and will then transmit a BYE. When this BYE times out, it will not ever be marked as ALREADYGONE, so when __sip_autodestruct is called again, we end up starting the cycle over.

This patch adds a call to sip_alreadygone(pkt->owner) in retrans_pkt in the case of a BYE that has timed out. This should prevent Asterisk from trying to transmit new BYE messages in the future.
Modified Asterisk to sleep for 2 seconds before sending the transfer NOTIFY to give me time to unplug the network cable from the transfering phone. Registered 3 phones A, B, and C. A calls B, A atxfer to C. I often (but not always) got infinite BYEs. After the patch I did not.

Diff revision 1 (Latest)

  1. /branches/1.4/channels/chan_sip.c: Loading...
/branches/1.4/channels/chan_sip.c
Revision 302087 New Change
[20] 2091 lines
[+20] [+] static int retrans_pkt(const void *data)
2092
		}
2092
		}
2093
	}
2093
	}
2094

    
   
2094

   
2095
	if (pkt->method == SIP_BYE) {
2095
	if (pkt->method == SIP_BYE) {
2096
		/* We're not getting answers on SIP BYE's.  Tear down the call anyway. */
2096
		/* We're not getting answers on SIP BYE's.  Tear down the call anyway. */

    
   
2097
		sip_alreadygone(pkt->owner);
2097
		if (pkt->owner->owner)
2098
		if (pkt->owner->owner)
2098
			ast_channel_unlock(pkt->owner->owner);
2099
			ast_channel_unlock(pkt->owner->owner);
2099
		append_history(pkt->owner, "ByeFailure", "Remote peer doesn't respond to bye. Destroying call anyway.");
2100
		append_history(pkt->owner, "ByeFailure", "Remote peer doesn't respond to bye. Destroying call anyway.");
2100
		ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);
2101
		ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);
2101
	}
2102
	}
[+20] [20] 18069 lines
  1. /branches/1.4/channels/chan_sip.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.