From 2e2d3827da2ee3088a6b3c2f9db81f9dbd9640ab Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Wed, 26 Apr 2017 16:43:42 -0700 Subject: [PATCH] Add check to ensure we don't overwrite existing connections --- builtin/logical/database/backend.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builtin/logical/database/backend.go b/builtin/logical/database/backend.go index 4bac4b0c36..da8c8384ac 100644 --- a/builtin/logical/database/backend.go +++ b/builtin/logical/database/backend.go @@ -78,12 +78,17 @@ func (b *databaseBackend) getDBObj(name string) (dbplugin.Database, bool) { // caches it in the connections map. The caller of this function needs to hold // the backend's write lock func (b *databaseBackend) createDBObj(s logical.Storage, name string) (dbplugin.Database, error) { + db, ok := b.connections[name] + if ok { + return db, nil + } + config, err := b.DatabaseConfig(s, name) if err != nil { return nil, err } - db, err := dbplugin.PluginFactory(config.PluginName, b.System(), b.logger) + db, err = dbplugin.PluginFactory(config.PluginName, b.System(), b.logger) if err != nil { return nil, err }