Perform some module use counting audits. This is now done outside the scope of the application/dialplan function so they do not need to worry about it.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89602 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2007-11-26 18:11:31 +00:00
parent 23eecf8c61
commit 0619fb1248
2 changed files with 5 additions and 37 deletions

View File

@@ -4306,8 +4306,8 @@ static int queue_function_queuememberlist(struct ast_channel *chan, const char *
/*! \brief Dialplan function QUEUE_MEMBER_PENALTY() /*! \brief Dialplan function QUEUE_MEMBER_PENALTY()
* Gets the members penalty. */ * Gets the members penalty. */
static int queue_function_memberpenalty_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { static int queue_function_memberpenalty_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
struct ast_module_user *lu; {
int penalty; int penalty;
AST_DECLARE_APP_ARGS(args, AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename); AST_APP_ARG(queuename);
@@ -4321,13 +4321,10 @@ static int queue_function_memberpenalty_read(struct ast_channel *chan, const cha
return -1; return -1;
} }
lu = ast_module_user_add(chan);
AST_STANDARD_APP_ARGS(args, data); AST_STANDARD_APP_ARGS(args, data);
if (args.argc < 2) { if (args.argc < 2) {
ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n"); ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n");
ast_module_user_remove(lu);
return -1; return -1;
} }
@@ -4336,14 +4333,13 @@ static int queue_function_memberpenalty_read(struct ast_channel *chan, const cha
if (penalty >= 0) /* remember that buf is already '\0' */ if (penalty >= 0) /* remember that buf is already '\0' */
snprintf (buf, len, "%d", penalty); snprintf (buf, len, "%d", penalty);
ast_module_user_remove(lu);
return 0; return 0;
} }
/*! Dialplan function QUEUE_MEMBER_PENALTY() /*! Dialplan function QUEUE_MEMBER_PENALTY()
* Sets the members penalty. */ * Sets the members penalty. */
static int queue_function_memberpenalty_write(struct ast_channel *chan, const char *cmd, char *data, const char *value) { static int queue_function_memberpenalty_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
struct ast_module_user *lu; {
int penalty; int penalty;
AST_DECLARE_APP_ARGS(args, AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename); AST_APP_ARG(queuename);
@@ -4355,34 +4351,27 @@ static int queue_function_memberpenalty_write(struct ast_channel *chan, const ch
return -1; return -1;
} }
lu = ast_module_user_add(chan);
AST_STANDARD_APP_ARGS(args, data); AST_STANDARD_APP_ARGS(args, data);
if (args.argc < 2) { if (args.argc < 2) {
ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n"); ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n");
ast_module_user_remove(lu);
return -1; return -1;
} }
penalty = atoi(value); penalty = atoi(value);
if (penalty < 0) { if (penalty < 0) {
ast_log(LOG_ERROR, "Invalid penalty\n"); ast_log(LOG_ERROR, "Invalid penalty\n");
ast_module_user_remove(lu);
return -1; return -1;
} }
if (ast_strlen_zero(args.interface)) { if (ast_strlen_zero(args.interface)) {
ast_log (LOG_ERROR, "<interface> parameter can't be null\n"); ast_log (LOG_ERROR, "<interface> parameter can't be null\n");
ast_module_user_remove(lu);
return -1; return -1;
} }
/* if queuename = NULL then penalty will be set for interface in all the queues. */ /* if queuename = NULL then penalty will be set for interface in all the queues. */
set_member_penalty(args.queuename, args.interface, penalty); set_member_penalty(args.queuename, args.interface, penalty);
ast_module_user_remove(lu);
return 0; return 0;
} }

View File

@@ -2235,9 +2235,6 @@ static int park_call_exec(struct ast_channel *chan, void *data)
/* Data is unused at the moment but could contain a parking /* Data is unused at the moment but could contain a parking
lot context eventually */ lot context eventually */
int res = 0; int res = 0;
struct ast_module_user *u;
u = ast_module_user_add(chan);
/* Setup the exten/priority to be s/1 since we don't know /* Setup the exten/priority to be s/1 since we don't know
where this call should return */ where this call should return */
@@ -2253,8 +2250,6 @@ static int park_call_exec(struct ast_channel *chan, void *data)
if (!res) if (!res)
res = park_call_full(chan, chan, 0, NULL, orig_chan_name); res = park_call_full(chan, chan, 0, NULL, orig_chan_name);
ast_module_user_remove(u);
return !res ? AST_PBX_KEEPALIVE : res; return !res ? AST_PBX_KEEPALIVE : res;
} }
@@ -2262,15 +2257,12 @@ static int park_call_exec(struct ast_channel *chan, void *data)
static int park_exec(struct ast_channel *chan, void *data) static int park_exec(struct ast_channel *chan, void *data)
{ {
int res = 0; int res = 0;
struct ast_module_user *u;
struct ast_channel *peer=NULL; struct ast_channel *peer=NULL;
struct parkeduser *pu; struct parkeduser *pu;
struct ast_context *con; struct ast_context *con;
int park = 0; int park = 0;
struct ast_bridge_config config; struct ast_bridge_config config;
u = ast_module_user_add(chan);
if (data) if (data)
park = atoi((char *)data); park = atoi((char *)data);
@@ -2336,7 +2328,6 @@ static int park_exec(struct ast_channel *chan, void *data)
if (error) { if (error) {
ast_log(LOG_WARNING, "Failed to play courtesy tone!\n"); ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
ast_hangup(peer); ast_hangup(peer);
ast_module_user_remove(u);
return -1; return -1;
} }
} else } else
@@ -2346,7 +2337,6 @@ static int park_exec(struct ast_channel *chan, void *data)
if (res < 0) { if (res < 0) {
ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, peer->name); ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, peer->name);
ast_hangup(peer); ast_hangup(peer);
ast_module_user_remove(u);
return -1; return -1;
} }
/* This runs sorta backwards, since we give the incoming channel control, as if it /* This runs sorta backwards, since we give the incoming channel control, as if it
@@ -2372,7 +2362,6 @@ static int park_exec(struct ast_channel *chan, void *data)
/* Simulate the PBX hanging up */ /* Simulate the PBX hanging up */
if (res != AST_PBX_NO_HANGUP_PEER) if (res != AST_PBX_NO_HANGUP_PEER)
ast_hangup(peer); ast_hangup(peer);
ast_module_user_remove(u);
return res; return res;
} else { } else {
/*! \todo XXX Play a message XXX */ /*! \todo XXX Play a message XXX */
@@ -2382,8 +2371,6 @@ static int park_exec(struct ast_channel *chan, void *data)
res = -1; res = -1;
} }
ast_module_user_remove(u);
return res; return res;
} }
@@ -3147,7 +3134,6 @@ END_OPTIONS );
*/ */
static int bridge_exec(struct ast_channel *chan, void *data) static int bridge_exec(struct ast_channel *chan, void *data)
{ {
struct ast_module_user *u;
struct ast_channel *current_dest_chan, *final_dest_chan; struct ast_channel *current_dest_chan, *final_dest_chan;
char *tmp_data = NULL; char *tmp_data = NULL;
struct ast_flags opts = { 0, }; struct ast_flags opts = { 0, };
@@ -3163,8 +3149,6 @@ static int bridge_exec(struct ast_channel *chan, void *data)
return -1; return -1;
} }
u = ast_module_user_add(chan);
tmp_data = ast_strdupa(data); tmp_data = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp_data); AST_STANDARD_APP_ARGS(args, tmp_data);
if (!ast_strlen_zero(args.options)) if (!ast_strlen_zero(args.options))
@@ -3182,7 +3166,6 @@ static int bridge_exec(struct ast_channel *chan, void *data)
"Channel2: %s\r\n", "Channel2: %s\r\n",
chan->name, args.dest_chan); chan->name, args.dest_chan);
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP"); pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP");
ast_module_user_remove(u);
return 0; return 0;
} }
@@ -3197,7 +3180,6 @@ static int bridge_exec(struct ast_channel *chan, void *data)
"Channel1: %s\r\n" "Channel1: %s\r\n"
"Channel2: %s\r\n", chan->name, args.dest_chan); "Channel2: %s\r\n", chan->name, args.dest_chan);
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT"); pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT");
ast_module_user_remove(u);
return 0; return 0;
} }
ast_channel_unlock(current_dest_chan); ast_channel_unlock(current_dest_chan);
@@ -3229,7 +3211,6 @@ static int bridge_exec(struct ast_channel *chan, void *data)
"Channel2: %s\r\n", chan->name, final_dest_chan->name); "Channel2: %s\r\n", chan->name, final_dest_chan->name);
ast_hangup(final_dest_chan); /* may be we should return this channel to the PBX? */ ast_hangup(final_dest_chan); /* may be we should return this channel to the PBX? */
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "INCOMPATIBLE"); pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "INCOMPATIBLE");
ast_module_user_remove(u);
return 0; return 0;
} }
@@ -3267,8 +3248,6 @@ static int bridge_exec(struct ast_channel *chan, void *data)
ast_hangup(final_dest_chan); ast_hangup(final_dest_chan);
} }
ast_module_user_remove(u);
return 0; return 0;
} }