summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-05-21 22:45:41 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-05-21 22:45:41 +0000
commitc857131945b90dbb44754dfc974b0809635acaaa (patch)
treeb9ccb1215d0b3d54876e8431d785cf3d957a42a0 /main/channel.c
parentab4c9f2247d6534ceebba984eac9c8269c8204aa (diff)
Made ast_queue_hangup() and ast_queue_hangup_with_cause() lock instead of trylock.
It made no sense to trylock the channel and then unconditionally lock the channel right after. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@367227 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/main/channel.c b/main/channel.c
index 469e97bad..2ccd18f3e 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1313,44 +1313,51 @@ int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
int ast_queue_hangup(struct ast_channel *chan)
{
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
+ int res;
+
/* Yeah, let's not change a lock-critical value without locking */
- if (!ast_channel_trylock(chan)) {
- ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
- manager_event(EVENT_FLAG_CALL, "HangupRequest",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan));
- ast_channel_unlock(chan);
- }
- return ast_queue_frame(chan, &f);
+ ast_channel_lock(chan);
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
+
+ manager_event(EVENT_FLAG_CALL, "HangupRequest",
+ "Channel: %s\r\n"
+ "Uniqueid: %s\r\n",
+ ast_channel_name(chan),
+ ast_channel_uniqueid(chan));
+
+ res = ast_queue_frame(chan, &f);
+ ast_channel_unlock(chan);
+ return res;
}
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
{
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
+ int res;
- if (cause >= 0)
+ if (cause >= 0) {
f.data.uint32 = cause;
+ }
/* Yeah, let's not change a lock-critical value without locking */
- if (!ast_channel_trylock(chan)) {
- ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
- if (cause < 0)
- f.data.uint32 = ast_channel_hangupcause(chan);
-
- manager_event(EVENT_FLAG_CALL, "HangupRequest",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "Cause: %d\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan),
- cause);
- ast_channel_unlock(chan);
+ ast_channel_lock(chan);
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
+ if (cause < 0) {
+ f.data.uint32 = ast_channel_hangupcause(chan);
}
- return ast_queue_frame(chan, &f);
+ manager_event(EVENT_FLAG_CALL, "HangupRequest",
+ "Channel: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Cause: %d\r\n",
+ ast_channel_name(chan),
+ ast_channel_uniqueid(chan),
+ cause);
+
+ res = ast_queue_frame(chan, &f);
+ ast_channel_unlock(chan);
+ return res;
}
/*! \brief Queue a control frame */