[svn-commits] tilghman: trunk r130232 - in /trunk: include/asterisk/res_odbc.h res/res_odbc.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 11 14:53:39 CDT 2008


Author: tilghman
Date: Fri Jul 11 14:53:38 2008
New Revision: 130232

URL: http://svn.digium.com/view/asterisk?view=rev&rev=130232
Log:
Add some debug code and add a missing release

Modified:
    trunk/include/asterisk/res_odbc.h
    trunk/res/res_odbc.c

Modified: trunk/include/asterisk/res_odbc.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/res_odbc.h?view=diff&rev=130232&r1=130231&r2=130232
==============================================================================
--- trunk/include/asterisk/res_odbc.h (original)
+++ trunk/include/asterisk/res_odbc.h Fri Jul 11 14:53:38 2008
@@ -40,6 +40,11 @@
 	SQLHDBC  con;                   /* ODBC Connection Handle */
 	struct odbc_class *parent;      /* Information about the connection is protected */
 	struct timeval last_used;
+#ifdef DEBUG_THREADS
+	char file[80];
+	char function[80];
+	int lineno;
+#endif
 	unsigned int used:1;
 	unsigned int up:1;
 	AST_LIST_ENTRY(odbc_obj) list;
@@ -100,7 +105,12 @@
  * thread which requests it.  Note that all connections should be released
  * when the thread is done by calling odbc_release_obj(), below.
  */
+#ifdef DEBUG_THREADS
+struct odbc_obj *_ast_odbc_request_obj(const char *name, int check, const char *file, const char *function, int lineno);
+#define ast_odbc_request_obj(a, b)	_ast_odbc_request_obj(a, b, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#else
 struct odbc_obj *ast_odbc_request_obj(const char *name, int check);
+#endif
 
 /*! 
  * \brief Releases an ODBC object previously allocated by odbc_request_obj()

Modified: trunk/res/res_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_odbc.c?view=diff&rev=130232&r1=130231&r2=130232
==============================================================================
--- trunk/res/res_odbc.c (original)
+++ trunk/res/res_odbc.c Fri Jul 11 14:53:38 2008
@@ -143,6 +143,9 @@
 	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 @@
 
 				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 @@
 	/* 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 @@
 	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;
@@ -720,6 +739,12 @@
 		ast_odbc_sanity_check(obj);
 	} 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;
 }




More information about the svn-commits mailing list