summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2013-08-02 14:05:07 +0000
committerMark Michelson <mmichelson@digium.com>2013-08-02 14:05:07 +0000
commitf8622e7c5cbdda91a5efad230a9e3af593378c7c (patch)
treeac2c4b5f2256fb55c84fb8915d82298d23c0e188 /channels/chan_sip.c
parent57a8148ccd704f02f33c65d902b199f4205e5480 (diff)
Get rid of ast_bridged_channel() and the bridged_channel field on ast_channels.
This commit is smaller than the initial review placed on review board. This is because a change to allow for channel drivers to access parking functionality externally was committed and invalidated quite a few of the changes initially made. (closes issue ASTERISK-22039) reported by Matt Jordan Review: https://reviewboard.asterisk.org/r/2717 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396103 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 1b5f104e0..736c15005 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -7271,7 +7271,7 @@ static int sip_hangup(struct ast_channel *ast)
}
if (!p->pendinginvite) {
- struct ast_channel *bridge = ast_bridged_channel(oldowner);
+ RAII_VAR(struct ast_channel *, bridge, ast_channel_bridge_peer(oldowner), ast_channel_cleanup);
char quality_buf[AST_MAX_USER_FIELD], *quality;
/* We need to get the lock on bridge because ast_rtp_instance_set_stats_vars will attempt
@@ -7282,7 +7282,6 @@ static int sip_hangup(struct ast_channel *ast)
do {
CHANNEL_DEADLOCK_AVOIDANCE(oldowner);
} while (sip_pvt_trylock(p));
- bridge = ast_bridged_channel(oldowner);
}
if (p->rtp) {
@@ -18007,10 +18006,22 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
/* Give useful transfer information to the dialplan */
if (transferer->owner) {
- struct ast_channel *peer = ast_bridged_channel(transferer->owner);
+ RAII_VAR(struct ast_channel *, peer, ast_channel_bridge_peer(transferer->owner), ast_channel_cleanup);
+
+ /*! pbx_builtin_setvar_helper will attempt to lock the channel. We need
+ * to be sure it's already locked here so we don't deadlock.
+ */
+ while (peer && ast_channel_trylock(peer)) {
+ sip_pvt_unlock(transferer);
+ do {
+ CHANNEL_DEADLOCK_AVOIDANCE(transferer->owner);
+ } while (sip_pvt_trylock(transferer));
+ }
+
if (peer) {
pbx_builtin_setvar_helper(peer, "SIPREFERRINGCONTEXT", transferer->context);
pbx_builtin_setvar_helper(peer, "SIPREFERREDBYHDR", p_referred_by);
+ ast_channel_unlock(peer);
}
}
@@ -26354,7 +26365,6 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
{
struct ast_channel *c=NULL;
int res;
- struct ast_channel *bridged_to;
const char *required;
/* If we have an INCOMING invite that we haven't answered, terminate that transaction */
@@ -26375,7 +26385,7 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
/* Get RTCP quality before end of call */
if (p->do_history || p->owner) {
char quality_buf[AST_MAX_USER_FIELD], *quality;
- struct ast_channel *bridge = p->owner ? ast_bridged_channel(p->owner) : NULL;
+ RAII_VAR(struct ast_channel *, bridge, p->owner ? ast_channel_bridge_peer(p->owner) : NULL, ast_channel_cleanup);
/* We need to get the lock on bridge because ast_rtp_instance_set_stats_vars will attempt
* to lock the bridge. This may get hairy...
@@ -26388,7 +26398,6 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
usleep(1);
sip_pvt_lock(p);
} while (p->owner && ast_channel_trylock(p->owner));
- bridge = p->owner ? ast_bridged_channel(p->owner) : NULL;
}
@@ -26452,7 +26461,7 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
if (!res) {
c = p->owner;
if (c) {
- bridged_to = ast_bridged_channel(c);
+ RAII_VAR(struct ast_channel *, bridged_to, ast_channel_bridge_peer(c), ast_channel_cleanup);
if (bridged_to) {
/* Don't actually hangup here... */
ast_queue_unhold(c);