aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-17 18:49:20 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-17 18:49:20 +0000
commit2a22b3a479a4d109af680c80cbad31831fe28af5 (patch)
tree0fc8d6c16d15fdee2f8740d5c2d25064ffc5b49f /funcs
parentb6cc1075c4240cd88772c6975a5d811fce057269 (diff)
Add assertions in the quest to track down a refcount leak.
(closes issue #14485) Reported by: davevg git-svn-id: http://svn.digium.com/svn/asterisk/trunk@176592 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_odbc.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index e23dff5f2..d56a1df27 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -338,8 +338,10 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
}
- if (obj)
+ if (obj) {
ast_odbc_release_obj(obj);
+ obj = NULL;
+ }
if (chan)
ast_autoservice_stop(chan);
@@ -443,6 +445,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
ast_log(LOG_ERROR, "Unable to execute query [%s]\n", ast_str_buffer(sql));
if (obj) {
ast_odbc_release_obj(obj);
+ obj = NULL;
}
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
if (chan) {
@@ -460,6 +463,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
SQLCloseCursor(stmt);
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
if (chan) {
ast_autoservice_stop(chan);
@@ -486,6 +490,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
if (chan)
@@ -528,6 +533,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", "MEMERROR");
if (chan)
@@ -625,6 +631,7 @@ end_acf_read:
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
if (chan)
ast_autoservice_stop(chan);
if (bogus_chan)
@@ -637,6 +644,7 @@ end_acf_read:
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
if (chan)
ast_autoservice_stop(chan);
if (bogus_chan)
@@ -1056,6 +1064,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
ast_debug(1, "Got obj\n");
if (!(stmt = ast_odbc_direct_execute(obj, generic_execute, ast_str_buffer(sql)))) {
ast_odbc_release_obj(obj);
+ obj = NULL;
continue;
}
@@ -1067,6 +1076,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
SQLCloseCursor(stmt);
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
AST_RWLIST_UNLOCK(&queries);
return CLI_SUCCESS;
}
@@ -1076,6 +1086,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
if (res == SQL_NO_DATA) {
ast_cli(a->fd, "Returned %d rows. Query executed on handle %d:%s [%s]\n", rows, dsn, query->readhandle[dsn], ast_str_buffer(sql));
break;
@@ -1103,27 +1114,33 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
AST_RWLIST_UNLOCK(&queries);
return CLI_SUCCESS;
}
ast_cli(a->fd, "%-20.20s %s\n", colname, ast_str_buffer(coldata));
}
+ rows++;
+
/* Get next row */
res = SQLFetch(stmt);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
break;
}
ast_cli(a->fd, "%-20.20s %s\n", "----------", "----------");
- rows++;
}
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
- ast_cli(a->fd, "Returned %d rows. Query executed on handle %d [%s]\n", rows, dsn, query->readhandle[dsn]);
+ obj = NULL;
+ ast_cli(a->fd, "Returned %d row%s. Query executed on handle %d [%s]\n", rows, rows == 1 ? "" : "s", dsn, query->readhandle[dsn]);
break;
}
- ast_odbc_release_obj(obj);
+ if (obj) {
+ ast_odbc_release_obj(obj);
+ obj = NULL;
+ }
if (!executed) {
ast_cli(a->fd, "Failed to execute query. [%s]\n", ast_str_buffer(sql));
@@ -1252,6 +1269,7 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
}
if (!(stmt = ast_odbc_direct_execute(obj, generic_execute, ast_str_buffer(sql)))) {
ast_odbc_release_obj(obj);
+ obj = NULL;
continue;
}
@@ -1259,6 +1277,7 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
+ obj = NULL;
ast_cli(a->fd, "Affected %d rows. Query executed on handle %d [%s]\n", (int)rows, dsn, query->writehandle[dsn]);
executed = 1;
break;