diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2007-08-11 05:28:08 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2007-08-11 05:28:08 +0000 |
commit | 89588a043facd19911a47c57d752b025ccfb99d5 (patch) | |
tree | 3ac801411e2d9c1cec743b214947d6ee99aa71e7 | |
parent | 9b3c3f1c615fed812782cb03098589dd5ca89a24 (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: https://origsvn.digium.com/svn/asterisk/trunk@79147 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | res/res_odbc.c | 12 |
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. */ |