Add global parser memory db handle code
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 8 Mar 2021 05:29:58 +0000 (14:29 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 8 Mar 2021 05:29:58 +0000 (14:29 +0900)
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/database/db_handle_provider.cc
src/common/database/db_handle_provider.hh

index 56a42ce..8e7c7ab 100644 (file)
@@ -55,6 +55,7 @@ std::unordered_map<uid_t, std::unique_ptr<DBHandleProvider>>
 bool DBHandleProvider::is_memory_ = false;
 
 DBHandleProvider::DBHandleProvider(uid_t uid) : uid_(uid),
+    global_parser_memory_db_handle_(nullptr, sqlite3_close_v2),
     parser_memory_db_handle_(nullptr, sqlite3_close_v2),
     cert_memory_db_handle_(nullptr, sqlite3_close_v2) {
   char *tmp_path = getUserPkgParserDBPathUID(GetGlobalUID());
@@ -156,6 +157,10 @@ void DBHandleProvider::SetMemoryMode(bool flag) {
         parser_memory_db_path_);
     if (parser_db != nullptr)
       parser_memory_db_handle_.reset(parser_db);
+    sqlite3* global_parser_file_db = GetMemoryDBHandle(global_parser_file_db_path_,
+        global_parser_memory_db_path_);
+    if (global_parser_file_db)
+      global_parser_memory_db_handle_.reset(global_parser_file_db);
     sqlite3* cert_db = GetMemoryDBHandle(cert_file_db_path_,
         cert_memory_db_path_);
     if (cert_db != nullptr)
@@ -163,6 +168,7 @@ void DBHandleProvider::SetMemoryMode(bool flag) {
   } else {
     parser_memory_db_handle_.reset(nullptr);
     cert_memory_db_handle_.reset(nullptr);
+    global_parser_memory_db_handle_.reset(nullptr);
   }
 
   LOGD("Set Memory mode : %s", flag ? "Memory" : "File");
index 57fba66..a9daba7 100644 (file)
@@ -50,6 +50,7 @@ class EXPORT_API DBHandleProvider {
  private:
   static std::unordered_map<uid_t, std::unique_ptr<DBHandleProvider>> provider_;
   uid_t uid_;
+  std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*> global_parser_memory_db_handle_;
   std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*> parser_memory_db_handle_;
   std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*> cert_memory_db_handle_;
   std::string parser_memory_db_path_;