[asterisk-commits] mmichelson: branch 1.6.0 r183245 - in /branches/1.6.0: ./ apps/app_queue.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 19 13:11:20 CDT 2009


Author: mmichelson
Date: Thu Mar 19 13:11:16 2009
New Revision: 183245

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183245
Log:
Merged revisions 183244 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r183244 | mmichelson | 2009-03-19 13:10:34 -0500 (Thu, 19 Mar 2009) | 16 lines
  
  Fix a memory leak associated with queues.
  
  For every attempt that app_queue made to place an outbound call to a queue member,
  we would allocate a queue_end_bridge structure. When the bridge for the call had
  completed, we would free the structure. Unfortunately not all call attempts actually
  end up bridged to a member, so we need to be more selective of when to allocate
  the structure. With this change, the allocation occurs in an area where we can
  guarantee that the call will be bridged.
  
  (closes issue #14680)
  Reported by: caspy
  Patches:
        14680.patch uploaded by mmichelson (license 60)
  Tested by: caspy
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/apps/app_queue.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/apps/app_queue.c?view=diff&rev=183245&r1=183244&r2=183245
==============================================================================
--- branches/1.6.0/apps/app_queue.c (original)
+++ branches/1.6.0/apps/app_queue.c Thu Mar 19 13:11:16 2009
@@ -3361,19 +3361,6 @@
 
 		}
 
-	if ((queue_end_bridge = ao2_alloc(sizeof(*queue_end_bridge), NULL))) {
-		queue_end_bridge->q = qe->parent;
-		queue_end_bridge->chan = qe->chan;
-		bridge_config.end_bridge_callback = end_bridge_callback;
-		bridge_config.end_bridge_callback_data = queue_end_bridge;
-		bridge_config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup;
-		/* Since queue_end_bridge can survive beyond the life of this call to Queue, we need
-		 * to make sure to increase the refcount of this queue so it cannot be freed until we
-		 * are done with it. We remove this reference in end_bridge_callback.
-		 */
-		queue_ref(qe->parent);
-	}
-
 	/* Hold the lock while we setup the outgoing calls */
 	if (use_weight)
 		ao2_lock(queues);
@@ -3902,6 +3889,20 @@
 					qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
 		ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
 		ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
+	
+		if ((queue_end_bridge = ao2_alloc(sizeof(*queue_end_bridge), NULL))) {
+			queue_end_bridge->q = qe->parent;
+			queue_end_bridge->chan = qe->chan;
+			bridge_config.end_bridge_callback = end_bridge_callback;
+			bridge_config.end_bridge_callback_data = queue_end_bridge;
+			bridge_config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup;
+			/* Since queue_end_bridge can survive beyond the life of this call to Queue, we need
+			 * to make sure to increase the refcount of this queue so it cannot be freed until we
+			 * are done with it. We remove this reference in end_bridge_callback.
+			 */
+			queue_ref(qe->parent);
+		}
+
 		time(&callstart);
 		transfer_ds = setup_transfer_datastore(qe, member, callstart, callcompletedinsl);
 		bridge = ast_bridge_call(qe->chan,peer, &bridge_config);




More information about the asterisk-commits mailing list