[Asterisk-code-review] app queue: Fix locking behavior is statis message handlers (asterisk[13])
Sean Bright
asteriskteam at digium.com
Thu Mar 16 08:45:38 CDT 2017
Sean Bright has uploaded a new change for review. ( https://gerrit.asterisk.org/5226 )
Change subject: app_queue: Fix locking behavior is statis message handlers
......................................................................
app_queue: Fix locking behavior is statis message handlers
The 'dying' flag in queue_stasis_data is read in several places without
appropriately locking the object first.
Change-Id: I246b7dbff8447acc957a1299f6ad0ebd0fd39088
---
M apps/app_queue.c
1 file changed, 14 insertions(+), 10 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/26/5226/1
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 65f1bf5..74e9f6e 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -5884,6 +5884,7 @@
{
struct queue_stasis_data *queue_data = userdata;
struct ast_bridge_blob *enter_blob = stasis_message_data(msg);
+ SCOPED_AO2LOCK(lock, queue_data);
if (queue_data->dying) {
return;
@@ -5983,15 +5984,16 @@
RAII_VAR(struct ast_channel_snapshot *, caller_snapshot, NULL, ao2_cleanup);
RAII_VAR(struct ast_channel_snapshot *, member_snapshot, NULL, ao2_cleanup);
- if (queue_data->dying) {
- return;
- }
-
if (transfer_msg->result != AST_BRIDGE_TRANSFER_SUCCESS) {
return;
}
ao2_lock(queue_data);
+
+ if (queue_data->dying) {
+ ao2_unlock(queue_data);
+ return;
+ }
if (ast_strlen_zero(queue_data->bridge_uniqueid) ||
strcmp(queue_data->bridge_uniqueid, transfer_msg->bridge->uniqueid)) {
@@ -6040,16 +6042,17 @@
RAII_VAR(struct ast_channel_snapshot *, caller_snapshot, NULL, ao2_cleanup);
RAII_VAR(struct ast_channel_snapshot *, member_snapshot, NULL, ao2_cleanup);
- if (queue_data->dying) {
- return;
- }
-
if (atxfer_msg->result != AST_BRIDGE_TRANSFER_SUCCESS ||
atxfer_msg->dest_type == AST_ATTENDED_TRANSFER_DEST_THREEWAY) {
return;
}
ao2_lock(queue_data);
+
+ if (queue_data->dying) {
+ ao2_unlock(queue_data);
+ return;
+ }
if (ast_strlen_zero(queue_data->bridge_uniqueid)) {
ao2_unlock(queue_data);
@@ -6234,11 +6237,12 @@
RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
enum agent_complete_reason reason;
+ ao2_lock(queue_data);
+
if (queue_data->dying) {
+ ao2_unlock(queue_data);
return;
}
-
- ao2_lock(queue_data);
if (!strcmp(channel_blob->snapshot->uniqueid, queue_data->caller_uniqueid)) {
reason = CALLER;
--
To view, visit https://gerrit.asterisk.org/5226
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I246b7dbff8447acc957a1299f6ad0ebd0fd39088
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
More information about the asterisk-code-review
mailing list