From 8d4afb9c19a6ef449e1978352de51f0e114dadc6 Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Sat, 23 Aug 2003 22:27:10 +0000
Subject: [PATCH] Fix call pickup with SIP

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

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 5099c2a8bd..7934d63d7e 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -4752,22 +4752,23 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
 						transmit_response_reliable(p, "503 Unavailable", req);
 						c = NULL;
 					}
-				} else if (ast_pickup_call(c)) {
-					ast_log(LOG_NOTICE, "Nothing to pick up\n");
-					transmit_response_reliable(p, "503 Unavailable", req);
-					p->alreadygone = 1;
-					/* Unlock locks so ast_hangup can do its magic */
-					ast_mutex_unlock(&c->lock);
-					ast_mutex_unlock(&p->lock);
-					ast_hangup(c);
-					ast_mutex_lock(&p->lock);
-					c = NULL;
 				} else {
 					ast_mutex_unlock(&c->lock);
-					ast_mutex_unlock(&p->lock);
-					ast_hangup(c);
-					ast_mutex_lock(&p->lock);
-					c = NULL;
+					if (ast_pickup_call(c)) {
+						ast_log(LOG_NOTICE, "Nothing to pick up\n");
+						transmit_response_reliable(p, "503 Unavailable", req);
+						p->alreadygone = 1;
+						/* Unlock locks so ast_hangup can do its magic */
+						ast_mutex_unlock(&p->lock);
+						ast_hangup(c);
+						ast_mutex_lock(&p->lock);
+						c = NULL;
+					} else {
+						ast_mutex_unlock(&p->lock);
+						ast_hangup(c);
+						ast_mutex_lock(&p->lock);
+						c = NULL;
+					}
 				}
 				break;
 			case AST_STATE_RING:
-- 
GitLab