aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-23 18:09:14 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-23 18:09:14 +0000
commit056f6458fb64d7c01e00a7df142b31a0b52383fb (patch)
tree29600921708b334e2cac68a157231813541a11ef /res
parent4070216d0d44e0617580f276571c8856fa221dfd (diff)
Protect the object from changing while the 'odbc show' CLI command is running
(Closes issue #12704) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@118129 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_odbc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index b050c8cb9..964a0747b 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -417,9 +417,11 @@ static char *handle_cli_odbc_show(struct ast_cli_entry *e, int cmd, struct ast_c
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 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
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);