aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_odbc.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-11 05:23:04 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-11 05:23:04 +0000
commit741c2964bea85f6a86960d9e53d674eb1a0ebabc (patch)
tree4b9f58e8074e7edd6beb75daa6ca4c521f25cbe3 /res/res_odbc.c
parentb7a054bff609d63d314dad402126c3a7b1cd257d (diff)
Ensure the connection gets marked as used at allocation time (closes issue #10429, report and fix by mnicholson)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@79142 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_odbc.c')
-rw-r--r--res/res_odbc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index e523b9819..a88fa5b38 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -413,8 +413,16 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
}
ast_mutex_init(&obj->lock);
obj->parent = class;
- odbc_obj_connect(obj);
- AST_LIST_INSERT_TAIL(&class->odbc_obj, obj, list);
+ if (odbc_obj_connect(obj) == ODBC_FAIL) {
+ ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
+ ast_mutex_destroy(&obj->lock);
+ free(obj);
+ obj = NULL;
+ class->count--;
+ } else {
+ obj->used = 1;
+ AST_LIST_INSERT_TAIL(&class->odbc_obj, obj, list);
+ }
}
} else {
/* Non-pooled connection: multiple modules can use the same connection. */