From e0b49e7331aced07db94e46496ae53e4fbad968d Mon Sep 17 00:00:00 2001
From: Joshua Colp <jcolp@digium.com>
Date: Wed, 27 Feb 2013 16:19:51 +0000
Subject: [PATCH] Relax dialog checking in get_sip_pvt_byid_locked so it works
 when the dialog is forked.

(closes issue ASTERISK-20638)
Reported by: eelcob
Patches:
      pedantic-call-pickup-from-tag.patch uploaded by eelcob (license 6442)
........

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

Merged revisions 382174 from http://svn.asterisk.org/svn/asterisk/branches/11


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

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 249672729d..cdf020ad70 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -17661,7 +17661,10 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
 			frommismatch = !!strcmp(fromtag, sip_pvt_ptr->theirtag);
 			tomismatch = !!strcmp(totag, sip_pvt_ptr->tag);
 
-			if (frommismatch || tomismatch) {
+                        /* Don't check from if the dialog is not established, due to multi forking the from
+                         * can change when the call is not answered yet.
+                         */
+			if ((frommismatch && ast_test_flag(&sip_pvt_ptr->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED)) || tomismatch) {
 				sip_pvt_unlock(sip_pvt_ptr);
 				if (frommismatch) {
 					ast_debug(4, "Matched %s call for callid=%s - pedantic from tag check fails; their tag is %s our tag is %s\n",
-- 
GitLab