From 03a4a28a2e49dc44d971088a018b5a928a279e52 Mon Sep 17 00:00:00 2001
From: Walter Doekes <walter+asterisk@wjd.nu>
Date: Sun, 12 Oct 2014 08:13:07 +0000
Subject: [PATCH] chan_sip: Fix so asterisk won't send reINVITE after a BYE.

After a reINVITE glare situation, Asterisk would re-send the reINVITE
even though the call had been hung up in the mean time.  This patch
unschedules the reinvite when handling the BYE.

ASTERISK-22791 #close
Reported by: Paolo Compagnini
Tested by: Paolo Compagnini

Review: https://reviewboard.asterisk.org/r/4056/
(testcase is in review r4055)
........

Merged revisions 425296 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@425297 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_sip.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 5da170d2dc..5a77d49f64 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -26851,6 +26851,10 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
 		transmit_response(p, "200 OK", req);
 	}
 
+	/* Destroy any pending invites so we won't try to do another
+	 * scheduled reINVITE. */
+	AST_SCHED_DEL_UNREF(sched, p->waitid, dialog_unref(p, "decrement refcount from sip_destroy because waitid won't be scheduled"));
+
 	return 1;
 }
 
-- 
GitLab