Merged revisions 43873 via svnmerge from
authorBJ Weschke <bweschke@btwtech.com>
Thu, 28 Sep 2006 15:32:48 +0000 (15:32 +0000)
committerBJ Weschke <bweschke@btwtech.com>
Thu, 28 Sep 2006 15:32:48 +0000 (15:32 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r43873 | bweschke | 2006-09-28 11:29:21 -0400 (Thu, 28 Sep 2006) | 11 lines

Merged revisions 43871 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r43871 | bweschke | 2006-09-28 11:18:05 -0400 (Thu, 28 Sep 2006) | 3 lines

 Fix race condion crash with get_member_status (#7864 - tim_ringenbach reported and patched)

........

................

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43875 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_queue.c

index b680119..6539e2c 100644 (file)
@@ -463,11 +463,12 @@ enum queue_member_status {
        QUEUE_NORMAL
 };
 
-static enum queue_member_status get_member_status(const struct call_queue *q, int max_penalty)
+static enum queue_member_status get_member_status(struct call_queue *q, int max_penalty)
 {
        struct member *member;
        enum queue_member_status result = QUEUE_NO_MEMBERS;
 
+       ast_mutex_lock(&q->lock);
        for (member = q->members; member; member = member->next) {
                if (max_penalty && (member->penalty > max_penalty))
                        continue;
@@ -482,10 +483,12 @@ static enum queue_member_status get_member_status(const struct call_queue *q, in
                        result = QUEUE_NO_REACHABLE_MEMBERS;
                        break;
                default:
+                       ast_mutex_unlock(&q->lock);
                        return QUEUE_NORMAL;
                }
        }
        
+       ast_mutex_unlock(&q->lock);
        return result;
 }