summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2009-03-19 18:10:34 +0000
committerMark Michelson <mmichelson@digium.com>2009-03-19 18:10:34 +0000
commitb52d2dae2e90583f7b0e9467b81cdad9de95b93b (patch)
treea301dc1e0517d21efd0444a88a305a959657bf3a /apps
parent4210f17abbedd6ea383054b1832d3b03ac0b98d1 (diff)
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@183244 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_queue.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 66c8ec7cd..4da2eac72 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3583,19 +3583,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
}
- 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);
- }
-
/* if the calling channel has the ANSWERED_ELSEWHERE flag set, make sure this is inherited.
(this is mainly to support chan_local)
*/
@@ -4147,6 +4134,20 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
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);