From 0c675b23f2d7941cc15e43980ddb38b5271b6ef2 Mon Sep 17 00:00:00 2001 From: Teddy Reed Date: Thu, 13 Nov 2014 09:31:10 -0800 Subject: [PATCH] Fix testing (only requireInstance) for DBHandle once --- osquery/database/db_handle.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osquery/database/db_handle.cpp b/osquery/database/db_handle.cpp index 5f07caa9..bf98b0aa 100644 --- a/osquery/database/db_handle.cpp +++ b/osquery/database/db_handle.cpp @@ -92,8 +92,14 @@ std::shared_ptr DBHandle::getInstanceAtPath(const std::string& path) { std::shared_ptr DBHandle::getInstance(const std::string& path, bool in_memory) { - // Throw any possible exceptions before the accessor. - requireInstance(path, in_memory); + static bool valid_instance = false; + if (!valid_instance) { + // Throw any possible exceptions before the accessor. + // Workaround for issue #423 + requireInstance(path, in_memory); + valid_instance = true; + } + static std::shared_ptr db_handle = std::shared_ptr(new DBHandle(path, in_memory)); return db_handle;