mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@6832 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user