diff options
author | Gregory Nietsky <gregory@distrotech.co.za> | 2011-10-23 14:35:26 +0000 |
---|---|---|
committer | Gregory Nietsky <gregory@distrotech.co.za> | 2011-10-23 14:35:26 +0000 |
commit | 3d55a05019d34eb8cc9ce5815e1248c0535cb601 (patch) | |
tree | 0d511f14fc0c94552b10661e3d921c714a3995e0 /apps/app_queue.c | |
parent | d36c70e0212261871dae1db259a5a8e0ee9e0473 (diff) |
Remove some ref leaks and a return without unlock.
There some resource leaks introduced in asterisk 10
make sure that locks are not held on return and we
release ref's held.
........
Merged revisions 341972 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@341973 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_queue.c')
-rw-r--r-- | apps/app_queue.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c index fee840c22..ce886df7f 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -3498,8 +3498,10 @@ static void rna(int rnatime, struct queue_ent *qe, char *interface, char *member time_t idletime = time(&idletime)-mem->lastcall; if ((mem->lastcall != 0) && (qe->parent->autopausedelay > idletime)) { ao2_unlock(qe->parent); + ao2_ref(mem, -1); return; } + ao2_ref(mem, -1); } ao2_unlock(qe->parent); } @@ -5759,7 +5761,7 @@ static int rqm_exec(struct ast_channel *chan, const char *data) switch (remove_from_queue(args.queuename, args.interface)) { case RES_OKAY: - if (!mem || ast_strlen_zero(mem->membername) || !log_membername_as_agent) { + if (!mem || ast_strlen_zero(mem->membername)) { ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", ""); } else { ast_queue_log(args.queuename, chan->uniqueid, mem->membername, "REMOVEMEMBER", "%s", ""); @@ -5785,6 +5787,10 @@ static int rqm_exec(struct ast_channel *chan, const char *data) break; } + if (mem) { + ao2_ref(mem, -1); + } + return res; } @@ -6360,12 +6366,15 @@ static int queue_function_mem_read(struct ast_channel *chan, const char *cmd, ch } else if (!strcasecmp(args.option, "penalty") && !ast_strlen_zero(args.interface) && ((m = interface_exists(q, args.interface)))) { count = m->penalty; + ao2_ref(m, -1); } else if (!strcasecmp(args.option, "paused") && !ast_strlen_zero(args.interface) && ((m = interface_exists(q, args.interface)))) { count = m->paused; + ao2_ref(m, -1); } else if (!strcasecmp(args.option, "ignorebusy") && !ast_strlen_zero(args.interface) && ((m = interface_exists(q, args.interface)))) { count = m->ignorebusy; + ao2_ref(m, -1); } ao2_unlock(q); queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER()"); @@ -6435,13 +6444,20 @@ static int queue_function_mem_write(struct ast_channel *chan, const char *cmd, c } } else { ast_log(LOG_ERROR, "Invalid option, only penalty , paused or ignorebusy are valid\n"); + ao2_ref(m, -1); + ao2_unlock(q); + ao2_ref(q, -1); return -1; } + ao2_ref(m, -1); } else { - ast_log(LOG_ERROR, "Invalid interface or queue\n"); + ao2_unlock(q); + ao2_ref(q, -1); + ast_log(LOG_ERROR, "Invalid interface for queue\n"); return -1; } ao2_unlock(q); + ao2_ref(q, -1); } else { ast_log(LOG_ERROR, "Invalid queue\n"); return -1; @@ -7619,7 +7635,7 @@ static int manager_remove_queue_member(struct mansession *s, const struct messag switch (remove_from_queue(queuename, interface)) { case RES_OKAY: - if (!mem || ast_strlen_zero(mem->membername) || !log_membername_as_agent) { + if (!mem || ast_strlen_zero(mem->membername)) { ast_queue_log(queuename, "MANAGER", interface, "REMOVEMEMBER", "%s", ""); } else { ast_queue_log(queuename, "MANAGER", mem->membername, "REMOVEMEMBER", "%s", ""); @@ -7640,6 +7656,10 @@ static int manager_remove_queue_member(struct mansession *s, const struct messag break; } + if (mem) { + ao2_ref(mem, -1); + } + return 0; } @@ -7939,17 +7959,19 @@ static char *handle_queue_remove_member(struct ast_cli_entry *e, int cmd, struct queuename = a->argv[5]; interface = a->argv[3]; - if (log_membername_as_agent) { - mem = find_member_by_queuename_and_interface(queuename, interface); - } - switch (remove_from_queue(queuename, interface)) { case RES_OKAY: - if (!mem || ast_strlen_zero(mem->membername) || !log_membername_as_agent) { + if (log_membername_as_agent) { + mem = find_member_by_queuename_and_interface(queuename, interface); + } + if (!mem || ast_strlen_zero(mem->membername)) { ast_queue_log(queuename, "CLI", interface, "REMOVEMEMBER", "%s", ""); } else { ast_queue_log(queuename, "CLI", mem->membername, "REMOVEMEMBER", "%s", ""); } + if (mem) { + ao2_ref(mem, -1); + } ast_cli(a->fd, "Removed interface %s from queue '%s'\n", interface, queuename); return CLI_SUCCESS; case RES_EXISTS: |