[asterisk-commits] mmichelson: branch 1.4 r85958 - /branches/1.4/apps/app_queue.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Oct 16 16:14:35 CDT 2007
Author: mmichelson
Date: Tue Oct 16 16:14:34 2007
New Revision: 85958
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85958
Log:
Trying to remove a non-dynamic queue member via dynamic means can lead to some
interesting (read nasty) situations. This patch clears up the issue by making
only dynamic queue members removable via dynamic methods.
Modified:
branches/1.4/apps/app_queue.c
Modified: branches/1.4/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_queue.c?view=diff&rev=85958&r1=85957&r2=85958
==============================================================================
--- branches/1.4/apps/app_queue.c (original)
+++ branches/1.4/apps/app_queue.c Tue Oct 16 16:14:34 2007
@@ -124,6 +124,7 @@
#define RES_EXISTS (-1) /* Entry already exists */
#define RES_OUTOFMEMORY (-2) /* Out of memory */
#define RES_NOSUCHQUEUE (-3) /* No such queue */
+#define RES_NOT_DYNAMIC (-4) /* Member is not dynamic */
static char *app = "Queue";
@@ -2962,13 +2963,21 @@
continue;
}
- if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER | OBJ_UNLINK))) {
+ if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER))) {
+ /* XXX future changes should beware of this assumption!! */
+ if(!mem->dynamic) {
+ res = RES_NOT_DYNAMIC;
+ ao2_ref(mem, -1);
+ ast_mutex_unlock(&q->lock);
+ break;
+ }
q->membercount--;
manager_event(EVENT_FLAG_AGENT, "QueueMemberRemoved",
"Queue: %s\r\n"
"Location: %s\r\n"
"MemberName: %s\r\n",
q->name, mem->interface, mem->membername);
+ ao2_unlink(q->members, mem);
ao2_ref(mem, -1);
if (queue_persistent_members)
@@ -3343,6 +3352,11 @@
case RES_NOSUCHQUEUE:
ast_log(LOG_WARNING, "Unable to remove interface from queue '%s': No such queue\n", args.queuename);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOSUCHQUEUE");
+ res = 0;
+ break;
+ case RES_NOT_DYNAMIC:
+ ast_log(LOG_WARNING, "Unable to remove interface from queue '%s': '%s' is not a dynamic member\n", args.queuename, args.interface);
+ pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTDYNAMIC");
res = 0;
break;
}
@@ -4411,6 +4425,9 @@
case RES_OUTOFMEMORY:
astman_send_error(s, m, "Out of memory");
break;
+ case RES_NOT_DYNAMIC:
+ astman_send_error(s, m, "Member not dynamic");
+ break;
}
return 0;
@@ -4550,6 +4567,9 @@
return RESULT_FAILURE;
case RES_OUTOFMEMORY:
ast_cli(fd, "Out of memory\n");
+ return RESULT_FAILURE;
+ case RES_NOT_DYNAMIC:
+ ast_cli(fd, "Member not dynamic\n");
return RESULT_FAILURE;
default:
return RESULT_FAILURE;
More information about the asterisk-commits
mailing list