]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Ensure the connection gets marked as used at allocation time (closes issue #10429...
authorTilghman Lesher <tilghman@meg.abyt.es>
Sat, 11 Aug 2007 05:23:04 +0000 (05:23 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Sat, 11 Aug 2007 05:23:04 +0000 (05:23 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79142 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_odbc.c

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