Merged revisions 79142 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Sat, 11 Aug 2007 05:28:08 +0000 (05:28 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Sat, 11 Aug 2007 05:28:08 +0000 (05:28 +0000)
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

res/res_odbc.c

index c46029f..d688930 100644 (file)
@@ -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. */