aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-11 19:53:38 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-11 19:53:38 +0000
commit03b8be1724117da92bf9bf6e2b43236c94975f73 (patch)
treee45762ea87506d40952facb156ff5d6e964b9627 /res
parent34ce9ca0f3b000a0c6c2ac24f6903b90f2873fb2 (diff)
Add some debug code and add a missing release
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@130232 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_odbc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 2279096a9..674bc09e8 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -143,6 +143,9 @@ struct odbc_cache_tables *ast_odbc_find_table(const char *database, const char *
if (tableptr) {
AST_RWLIST_RDLOCK(&tableptr->columns);
AST_RWLIST_UNLOCK(&odbc_tables);
+ if (obj) {
+ ast_odbc_release_obj(obj);
+ }
return tableptr;
}
@@ -579,9 +582,16 @@ static char *handle_cli_odbc_show(struct ast_cli_entry *e, int cmd, struct ast_c
while ((current = ao2_iterator_next(&aoi2))) {
ast_mutex_lock(&current->lock);
+#ifdef DEBUG_THREADS
+ ast_cli(a->fd, " - Connection %d: %s (%s:%d %s)\n", ++count,
+ current->used ? "in use" :
+ current->up && ast_odbc_sanity_check(current) ? "connected" : "disconnected",
+ current->file, current->lineno, current->function);
+#else
ast_cli(a->fd, " - Connection %d: %s\n", ++count,
current->used ? "in use" :
current->up && ast_odbc_sanity_check(current) ? "connected" : "disconnected");
+#endif
ast_mutex_unlock(&current->lock);
ao2_ref(current, -1);
}
@@ -631,6 +641,11 @@ void ast_odbc_release_obj(struct odbc_obj *obj)
/* For pooled connections, this frees the connection to be
* reused. For non-pooled connections, it does nothing. */
obj->used = 0;
+#ifdef DEBUG_THREADS
+ obj->file[0] = '\0';
+ obj->function[0] = '\0';
+ obj->lineno = 0;
+#endif
ao2_ref(obj, -1);
}
@@ -639,7 +654,11 @@ int ast_odbc_backslash_is_escape(struct odbc_obj *obj)
return obj->parent->backslash_is_escape;
}
+#ifdef DEBUG_THREADS
+struct odbc_obj *_ast_odbc_request_obj(const char *name, int check, const char *file, const char *function, int lineno)
+#else
struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
+#endif
{
struct odbc_obj *obj = NULL;
struct odbc_class *class;
@@ -721,6 +740,12 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
} else if (obj && obj->parent->idlecheck > 0 && ast_tvdiff_sec(ast_tvnow(), obj->last_used) > obj->parent->idlecheck)
odbc_obj_connect(obj);
+#if DEBUG_THREADS
+ ast_copy_string(obj->file, file, sizeof(obj->file));
+ ast_copy_string(obj->function, function, sizeof(obj->function));
+ obj->lineno = lineno;
+#endif
+
return obj;
}