[Freeswitch-svn] [commit] r13455 - freeswitch/trunk/src/mod/applications/mod_commands
FreeSWITCH SVN
brian at freeswitch.org
Tue May 26 19:51:15 PDT 2009
Author: brian
Date: Tue May 26 21:51:15 2009
New Revision: 13455
Log:
fix leak and remove duplicate safe_free
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Tue May 26 21:51:15 2009
@@ -2062,12 +2062,13 @@
SWITCH_STANDARD_API(break_function)
{
switch_core_session_t *psession = NULL;
- char *mycmd, *flag;
+ char *mycmd = NULL, *flag;
switch_channel_t *channel = NULL;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
if (switch_strlen_zero(cmd)) {
stream->write_function(stream, "-USAGE: %s\n", BREAK_SYNTAX);
- return SWITCH_STATUS_SUCCESS;
+ goto done;
}
mycmd = strdup(cmd);
@@ -2079,7 +2080,7 @@
if (!(psession = switch_core_session_locate(mycmd))) {
stream->write_function(stream, "-ERR No Such Channel!\n");
- return SWITCH_STATUS_SUCCESS;
+ goto done;
}
if (flag && !strcasecmp(flag, "all")) {
@@ -2092,9 +2093,15 @@
} else {
switch_channel_set_flag(channel, CF_BREAK);
}
- switch_core_session_rwunlock(psession);
- return SWITCH_STATUS_SUCCESS;
+ done:
+ if (psession) {
+ switch_core_session_rwunlock(psession);
+ }
+
+ switch_safe_free(mycmd);
+
+ return status;
}
#define PAUSE_SYNTAX "<uuid> <on|off>"
@@ -2340,8 +2347,6 @@
if (api_task->recur) {
task->runtime = switch_epoch_time_now(NULL) + api_task->recur;
}
-
-
}
#define UNSCHED_SYNTAX "<task_id>"
@@ -2383,7 +2388,6 @@
if ((dcmd = strchr(group, ' '))) {
*dcmd++ = '\0';
-
if (*tm == '+') {
when = switch_epoch_time_now(NULL) + atol(tm + 1);
} else if (*tm == '@') {
@@ -2432,8 +2436,9 @@
char *arg;
switch_memory_pool_t *pool;
- if (!job)
+ if (!job) {
return NULL;
+ }
switch_thread_rwlock_rdlock(bgapi_rwlock);
@@ -2622,7 +2627,6 @@
#define COMPLETE_SYNTAX "add <word>|del [<word>|*]"
SWITCH_STANDARD_API(complete_function)
{
-
switch_status_t status;
if ((status = switch_console_set_complete(cmd)) == SWITCH_STATUS_SUCCESS) {
@@ -2637,7 +2641,6 @@
#define ALIAS_SYNTAX "add <alias> <command> | del [<alias>|*]"
SWITCH_STANDARD_API(alias_function)
{
-
switch_status_t status;
if ((status = switch_console_set_alias(cmd)) == SWITCH_STATUS_SUCCESS) {
@@ -2958,7 +2961,6 @@
switch_safe_free(mycmd);
stream->write_function(stream, "-ERR Usage: uuid_session_heartbeat %s", HEARTBEAT_SYNTAX);
return SWITCH_STATUS_SUCCESS;
-
}
SWITCH_STANDARD_API(uuid_flush_dtmf_function)
@@ -3156,7 +3158,6 @@
usage:
stream->write_function(stream, "-USAGE: %s\n", UUID_SEND_DTMF_SYNTAX);
- switch_safe_free(mycmd);
done:
if (psession) {
@@ -3263,7 +3264,6 @@
#define GLOBAL_GETVAR_SYNTAX "<var>"
SWITCH_STANDARD_API(global_getvar_function)
{
-
if (switch_strlen_zero(cmd)) {
switch_core_dump_variables(stream);
} else {
@@ -3352,7 +3352,6 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown)
{
int x;
-
for (x = 30; x > 0; x--) {
if (switch_thread_rwlock_trywrlock(bgapi_rwlock) == SWITCH_STATUS_SUCCESS) {
@@ -3372,7 +3371,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
{
switch_api_interface_t *commands_api_interface;
More information about the Freeswitch-svn
mailing list