aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_queue.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-19 18:19:02 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-19 18:19:02 +0000
commit58818426d60d583c4becc6a99b398cbac1b7b12f (patch)
tree5fee3540f8d72d45cd1b2e5bf15e5860581dd4f8 /apps/app_queue.c
parenta4d6ea67a7536e2cb2337527357ce6d3db8639f3 (diff)
Massive cleanups to applications for LOCAL_USER handling and some other things.
In general, LOCAL_USER_ADD/REMOVE should be the first/last thing called in an application. An exception is if there is some *fast* setup code that might halt the execution of the application, such as checking to see if an argument exists. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6832 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_queue.c')
-rwxr-xr-xapps/app_queue.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 27d73ca71..35558fd88 100755
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2556,25 +2556,27 @@ static int pqm_exec(struct ast_channel *chan, void *data)
struct localuser *u;
char *queuename, *interface;
- if (!data) {
+ if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "PauseQueueMember requires an argument ([queuename]|interface])\n");
return -1;
}
+ LOCAL_USER_ADD(u);
+
queuename = ast_strdupa((char *)data);
if (!queuename) {
ast_log(LOG_ERROR, "Out of memory\n");
+ LOCAL_USER_REMOVE(u);
return -1;
}
interface = strchr(queuename, '|');
if (!interface) {
ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename]|interface])\n");
+ LOCAL_USER_REMOVE(u);
return -1;
}
- LOCAL_USER_ADD(u);
-
*interface = '\0';
interface++;
@@ -2584,6 +2586,7 @@ static int pqm_exec(struct ast_channel *chan, void *data)
LOCAL_USER_REMOVE(u);
return 0;
}
+ LOCAL_USER_REMOVE(u);
return -1;
}
@@ -2597,25 +2600,27 @@ static int upqm_exec(struct ast_channel *chan, void *data)
struct localuser *u;
char *queuename, *interface;
- if (!data) {
+ if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "UnpauseQueueMember requires an argument ([queuename]|interface])\n");
return -1;
}
+ LOCAL_USER_ADD(u);
+
queuename = ast_strdupa((char *)data);
if (!queuename) {
ast_log(LOG_ERROR, "Out of memory\n");
+ LOCAL_USER_REMOVE(u);
return -1;
}
interface = strchr(queuename, '|');
if (!interface) {
ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename]|interface])\n");
+ LOCAL_USER_REMOVE(u);
return -1;
}
- LOCAL_USER_ADD(u);
-
*interface = '\0';
interface++;
@@ -2625,6 +2630,7 @@ static int upqm_exec(struct ast_channel *chan, void *data)
LOCAL_USER_REMOVE(u);
return 0;
}
+ LOCAL_USER_REMOVE(u);
return -1;
}
@@ -2641,19 +2647,20 @@ static int rqm_exec(struct ast_channel *chan, void *data)
char tmpchan[256]="";
char *interface = NULL;
- if (!data) {
+ if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "RemoveQueueMember requires an argument (queuename[|interface])\n");
return -1;
}
- info = ast_strdupa((char *)data);
+ LOCAL_USER_ADD(u);
+
+ info = ast_strdupa(data);
if (!info) {
ast_log(LOG_ERROR, "Out of memory\n");
+ LOCAL_USER_REMOVE(u);
return -1;
}
- LOCAL_USER_ADD(u);
-
queuename = info;
if (queuename) {
interface = strchr(queuename, '|');
@@ -2704,17 +2711,19 @@ static int aqm_exec(struct ast_channel *chan, void *data)
char *penaltys=NULL;
int penalty = 0;
- if (!data) {
+ if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[|[interface][|penalty]])\n");
return -1;
}
- info = ast_strdupa((char *)data);
+ LOCAL_USER_ADD(u);
+
+ info = ast_strdupa(data);
if (!info) {
ast_log(LOG_ERROR, "Out of memory\n");
+ LOCAL_USER_REMOVE(u);
return -1;
}
- LOCAL_USER_ADD(u);
queuename = info;
if (queuename) {
@@ -2794,7 +2803,7 @@ static int queue_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "Queue requires an argument: queuename[|options[|URL][|announceoverride][|timeout]]\n");
return -1;
}
-
+
LOCAL_USER_ADD(u);
/* Setup our queue entry */
@@ -3024,12 +3033,15 @@ static char *queue_function_qac(struct ast_channel *chan, char *cmd, char *data,
struct localuser *u;
struct member *m;
+ LOCAL_USER_ACF_ADD(u);
+
+ ast_copy_string(buf, "0", len);
+
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "QUEUEAGENTCOUNT requires an argument: queuename\n");
- return "0";
+ LOCAL_USER_REMOVE(u);
+ return buf;
}
-
- LOCAL_USER_ACF_ADD(u);
ast_mutex_lock(&qlock);