aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-23 16:48:37 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-23 16:48:37 +0000
commitc15317859128f379f17176135b1a05b24eb51d60 (patch)
tree1d189cd00289363afcb0b900339b728d1309eb01
parent10ba3de332116a3584e4b4df75bc5abe36bafb46 (diff)
Merged revisions 248397 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r248397 | dvossel | 2010-02-23 10:34:39 -0600 (Tue, 23 Feb 2010) | 15 lines Merged revisions 248396 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r248396 | dvossel | 2010-02-23 10:26:05 -0600 (Tue, 23 Feb 2010) | 9 lines fixes invite with replaces deadlock (closes issue #16862) Reported by: pwalker Patches: replaces_deadlock_1.4 uploaded by dvossel (license 671) Tested by: pwalker, dvossel ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@248399 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c70
1 files changed, 52 insertions, 18 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 7a83f2859..d6236b5db 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -18757,6 +18757,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
int gotdest;
const char *p_replaces;
char *replace_id = NULL;
+ int refer_locked = 0;
const char *required;
unsigned int required_profile = 0;
struct ast_channel *c = NULL; /* New channel */
@@ -18791,7 +18792,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
p->invitestate = INV_COMPLETED;
if (!p->lastinvite)
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
}
@@ -18818,7 +18820,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
transmit_response(p, "482 Loop Detected", req);
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- return 0;
+ res = 0;
+ goto request_invite_cleanup;
} else {
/*! This is a spiral. What we need to do is to just change the outgoing INVITE
* so that it now routes to the new Request URI. Since we created the INVITE ourselves
@@ -18844,7 +18847,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
*/
ast_string_field_set(p->owner, call_forward, peerorhost);
ast_queue_control(p->owner, AST_CONTROL_BUSY);
- return 0;
+ res = 0;
+ goto request_invite_cleanup;
}
}
@@ -18882,7 +18886,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
transmit_response_reliable(p, "491 Request Pending", req);
ast_debug(1, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
/* Don't destroy dialog here */
- return 0;
+ res = 0;
+ goto request_invite_cleanup;
}
}
@@ -18899,7 +18904,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
ast_debug(3, "INVITE w Replaces on existing call? Refusing action. [%s]\n", p->callid);
transmit_response_reliable(p, "400 Bad request", req); /* The best way to not not accept the transfer */
/* Do not destroy existing call */
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
if (sipdebug)
@@ -18913,7 +18919,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
append_history(p, "Xfer", "INVITE/Replace Failed. Out of memory.");
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
p->invitestate = INV_COMPLETED;
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
/* Todo: (When we find phones that support this)
@@ -18949,6 +18956,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-existent call id (%s)!\n", replace_id);
transmit_response_reliable(p, "481 Call Leg Does Not Exist (Replaces)", req);
error = 1;
+ } else {
+ refer_locked = 1;
}
/* At this point, bot the pvt and the owner of the call to be replaced is locked */
@@ -18988,8 +18997,10 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
ast_channel_unlock(p->refer->refer_call->owner);
}
}
+ refer_locked = 0;
p->invitestate = INV_COMPLETED;
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
}
@@ -19022,7 +19033,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
transmit_response_reliable(p, "488 Not acceptable here", req);
if (!p->lastinvite)
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
ast_queue_control(p->owner, AST_CONTROL_SRCUPDATE);
} else {
@@ -19042,7 +19054,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
res = check_user(p, req, SIP_INVITE, e, XMIT_RELIABLE, sin);
if (res == AUTH_CHALLENGE_SENT) {
p->invitestate = INV_COMPLETED; /* Needs to restart in another INVITE transaction */
- return 0;
+ res = 0;
+ goto request_invite_cleanup;
}
if (res < 0) { /* Something failed in authentication */
if (res == AUTH_FAKE_AUTH) {
@@ -19055,7 +19068,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
ast_string_field_set(p, theirtag, NULL);
- return 0;
+ res = 0;
+ goto request_invite_cleanup;
}
/* If T38 is needed but not present, then make it magically appear */
@@ -19072,7 +19086,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
ast_debug(1, "No compatible codecs for this SIP call.\n");
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
if (ast_test_flag(&p->flags[1], SIP_PAGE2_CONSTANT_SSRC)) {
if (p->rtp) {
@@ -19107,7 +19122,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
p->invitestate = INV_COMPLETED;
}
- return 0;
+ res = 0;
+ goto request_invite_cleanup;
}
gotdest = get_destination(p, NULL); /* Get destination right away */
get_rdnis(p, NULL); /* Get redirect information */
@@ -19134,7 +19150,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
p->invitestate = INV_COMPLETED;
update_call_counter(p, DEC_CALL_LIMIT);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- return 0;
+ res = 0;
+ goto request_invite_cleanup;
} else {
/* If no extension was specified, use the s one */
@@ -19188,7 +19205,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!p->lastinvite) {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
}
@@ -19202,7 +19220,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!p->lastinvite) {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
}
@@ -19216,7 +19235,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!p->lastinvite) {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
p->stimer->st_active_peer_ua = TRUE;
@@ -19246,7 +19266,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!p->lastinvite) {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
- return -1;
+ res = -1;
+ goto request_invite_cleanup;
}
break;
@@ -19306,7 +19327,10 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* Go and take over the target call */
if (sipdebug)
ast_debug(4, "Sending this call to the invite/replcaes handler %s\n", p->callid);
- return handle_invite_replaces(p, req, debug, seqno, sin, nounlock);
+ res = handle_invite_replaces(p, req, debug, seqno, sin, nounlock);
+ refer_locked = 0;
+ goto request_invite_cleanup;
+
}
@@ -19430,6 +19454,16 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
}
+
+request_invite_cleanup:
+
+ if (refer_locked && p->refer && p->refer->refer_call) {
+ sip_pvt_unlock(p->refer->refer_call);
+ if (p->refer->refer_call->owner) {
+ ast_channel_unlock(p->refer->refer_call->owner);
+ }
+ }
+
return res;
}