aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-11 05:28:08 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-11 05:28:08 +0000
commit7ff3213f001bf1227b9f6d99d3019ac21dbea906 (patch)
tree3ac801411e2d9c1cec743b214947d6ee99aa71e7
parentdd4bd2227b6b73265c4a11c0239bbe43efb5abe6 (diff)
Merged revisions 79142 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r79142 | tilghman | 2007-08-11 00:23:04 -0500 (Sat, 11 Aug 2007) | 2 lines 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/trunk@79147 f38db490-d61c-443f-a65b-d21fe96a405b
-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 c46029f02..d688930c1 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -416,8 +416,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. */