mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 16:20:37 +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:
@@ -38,6 +38,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include "asterisk/module.h"
|
||||
#include "asterisk/options.h"
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static const char *tdesc = "Transfer";
|
||||
|
||||
static const char *app = "Transfer";
|
||||
@@ -61,10 +65,6 @@ static const char *descrip =
|
||||
"successful and there exists a priority n + 101,\n"
|
||||
"then that priority will be taken next.\n" ;
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static int transfer_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res;
|
||||
@@ -81,12 +81,15 @@ static int transfer_exec(struct ast_channel *chan, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL_USER_ADD(u);
|
||||
|
||||
if ((slash = strchr(dest, '/')) && (len = (slash - dest))) {
|
||||
tech = dest;
|
||||
dest = slash + 1;
|
||||
/* Allow execution only if the Tech/destination agrees with the type of the channel */
|
||||
if (strncasecmp(chan->type, tech, len)) {
|
||||
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -94,11 +97,10 @@ static int transfer_exec(struct ast_channel *chan, void *data)
|
||||
/* Check if the channel supports transfer before we try it */
|
||||
if (!chan->tech->transfer) {
|
||||
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL_USER_ADD(u);
|
||||
|
||||
res = ast_transfer(chan, dest);
|
||||
|
||||
if (res < 0) {
|
||||
|
||||
Reference in New Issue
Block a user