[svn-commits] tilghman: trunk r118129 - /trunk/res/res_odbc.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 23 13:09:14 CDT 2008


Author: tilghman
Date: Fri May 23 13:09:14 2008
New Revision: 118129

URL: http://svn.digium.com/view/asterisk?view=rev&rev=118129
Log:
Protect the object from changing while the 'odbc show' CLI command is running
(Closes issue #12704)

Modified:
    trunk/res/res_odbc.c

Modified: trunk/res/res_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_odbc.c?view=diff&rev=118129&r1=118128&r2=118129
==============================================================================
--- trunk/res/res_odbc.c (original)
+++ trunk/res/res_odbc.c Fri May 23 13:09:14 2008
@@ -417,9 +417,11 @@
 				ast_cli(a->fd, "  Pooled: Yes\n  Limit:  %d\n  Connections in use: %d\n", class->limit, class->count);
 
 				while ((current = ao2_iterator_next(&aoi2))) {
+					ast_mutex_lock(&current->lock);
 					ast_cli(a->fd, "    - Connection %d: %s\n", ++count,
 						current->used ? "in use" :
 						current->up && ast_odbc_sanity_check(current) ? "connected" : "disconnected");
+					ast_mutex_unlock(&current->lock);
 					ao2_ref(current, -1);
 				}
 			} else {
@@ -497,7 +499,9 @@
 		aoi = ao2_iterator_init(class->obj_container, 0);
 		while ((obj = ao2_iterator_next(&aoi))) {
 			if (! obj->used) {
+				ast_mutex_lock(&obj->lock);
 				obj->used = 1;
+				ast_mutex_unlock(&obj->lock);
 				break;
 			}
 			ao2_ref(obj, -1);




More information about the svn-commits mailing list