From 62128ba7b78bc8a5c3e302e10638f5ef849328dc Mon Sep 17 00:00:00 2001
From: Olle Johansson <oej@edvina.net>
Date: Thu, 6 Apr 2006 21:01:06 +0000
Subject: [PATCH] - Don't change channel direction on re-invites - Don't
 re-initialize initreq on re-invites

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

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 58dcb4f6da..7ef5e04f7e 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10718,7 +10718,7 @@ static int handle_request_options(struct sip_pvt *p, struct sip_request *req, in
 static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin, int *recount, char *e)
 {
 	int res = 1;
-	struct ast_channel *c=NULL;
+	struct ast_channel *c=NULL;		/* New channel */
 	int gotdest;
 	char *supported;
 	char *required;
@@ -10730,6 +10730,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
 		if (supported)
 			parse_sip_options(p, supported);
 	}
+
+	/* Find out what they require */
 	required = get_header(req, "Required");
 	if (!ast_strlen_zero(required)) {
 		required_profile = parse_sip_options(NULL, required);
@@ -10766,17 +10768,18 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
 	}
 
 	if (!ignore) {
-		/* Use this as the basis */
-		if (debug)
-			ast_verbose("Using INVITE request as basis request - %s\n", p->callid);
 		sip_cancel_destroy(p);
-		/* This call is no longer outgoing if it ever was */
-		ast_clear_flag(&p->flags[0], SIP_OUTGOING);
+
 		/* This also counts as a pending invite */
 		p->pendinginvite = seqno;
-		copy_request(&p->initreq, req);
 		check_via(p, req);
-		if (p->owner) {
+
+		if (!p->owner) {	/* Not a re-invite */
+			/* Use this as the basis */
+			copy_request(&p->initreq, req);
+			if (debug)
+				ast_verbose("Using INVITE request as basis request - %s\n", p->callid);
+		} else {	/* Re-invite on existing call */
 			/* Handle SDP here if we already have an owner */
 			if (!strcasecmp(get_header(req, "Content-Type"), "application/sdp")) {
 				if (process_sdp(p, req)) {
-- 
GitLab