app_queue: fix a couple leaks to struct call_queue in set_member_value
authorCorey Farrell <git@cfware.com>
Thu, 30 Oct 2014 23:56:39 +0000 (23:56 +0000)
committerCorey Farrell <git@cfware.com>
Thu, 30 Oct 2014 23:56:39 +0000 (23:56 +0000)
set_member_value has a couple leaks to references in the variable q
found through testsuite tests/queues/set_penalty.  Also remove the
REF_DEBUG_ONLY_QUEUES compiler declaration, this is no longer possible
with the updated REF_DEBUG code.

ASTERISK-24466 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4125/
........

Merged revisions 426805 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 426806 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 426807 from http://svn.asterisk.org/svn/asterisk/branches/13

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

apps/app_queue.c

index 4d4449f..8d1653c 100644 (file)
@@ -114,9 +114,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/core_unreal.h"
 #include "asterisk/bridge_basic.h"
 
-/* Define, to debug reference counts on queues, without debugging reference counts on queue members */
-/* #define REF_DEBUG_ONLY_QUEUES */
-
 /*!
  * \par Please read before modifying this file.
  * There are three locks which are regularly used
@@ -1817,7 +1814,7 @@ static void queue_member_follower_removal(struct call_queue *queue, struct membe
        ao2_callback(queue->members, OBJ_NODATA | OBJ_MULTIPLE, queue_member_decrement_followers, &pos);
 }
 
-#ifdef REF_DEBUG_ONLY_QUEUES
+#ifdef REF_DEBUG
 #define queue_ref(q)                           _queue_ref(q, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define queue_unref(q)                         _queue_unref(q, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define queue_t_ref(q, tag)                    _queue_ref(q, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
@@ -7266,6 +7263,7 @@ static int set_member_value(const char *queuename, const char *interface, int pr
                                        if ((q = find_load_queue_rt_friendly(name))) {
                                                foundqueue++;
                                                foundinterface += set_member_value_help_members(q, interface, property, value);
+                                               queue_unref(q);
                                        }
                                }
                        }
@@ -7276,12 +7274,14 @@ static int set_member_value(const char *queuename, const char *interface, int pr
                while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
                        foundqueue++;
                        foundinterface += set_member_value_help_members(q, interface, property, value);
+                       queue_unref(q);
                }
                ao2_iterator_destroy(&queue_iter);
        } else { /* We actually have a queuename, so we can just act on the single queue. */
                if ((q = find_load_queue_rt_friendly(queuename))) {
                        foundqueue++;
                        foundinterface += set_member_value_help_members(q, interface, property, value);
+                       queue_unref(q);
                }
        }