Remove unnecessary unique_lock from read operation
[platform/core/appfw/pkgmgr-info.git] / src / server / database / cert_get_db_handler.cc
index 4a7b32b..881b84c 100644 (file)
@@ -19,6 +19,8 @@
 #include <shared_mutex>
 #include <vector>
 
+#include "utils/logging.hh"
+
 #include "pkgmgrinfo_debug.h"
 #include "pkgmgrinfo_internal.h"
 
@@ -26,7 +28,7 @@ namespace pkgmgr_server {
 namespace database {
 
 CertGetDBHandler::CertGetDBHandler(uid_t uid, int pid)
-    : AbstractDBHandler(uid, pid), uid_(uid) {}
+    : AbstractDBHandler(uid, pid), uid_(uid), handle_(nullptr) {}
 
 CertGetDBHandler::~CertGetDBHandler() {}
 
@@ -39,11 +41,13 @@ void CertGetDBHandler::SetPkgID(std::string pkgid) {
 }
 
 int CertGetDBHandler::Execute() {
-  std::shared_lock<std::shared_timed_mutex> s(lock_);
+  std::shared_lock<std::shared_mutex> s(lock_);
+
   SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
   SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_CERTDB);
+
   if (!Connect()) {
-    _LOGE("Failed to connect database");
+    LOG(ERROR) << "Failed to connect database";
     return PMINFO_R_ERROR;
   }
 
@@ -52,11 +56,10 @@ int CertGetDBHandler::Execute() {
   if (ret != PMINFO_R_OK)
     return ret;
 
-  handle_ = static_cast<pkgmgr_certinfo_x*>(handle);
+  handle_ = reinterpret_cast<pkgmgr_certinfo_x*>(handle);
   sqlite3* conn = GetConnection().front().first;
-  ret = certinfo_internal_get(conn, pkgid_.c_str(), uid_, handle_);
 
-  return ret;
+  return certinfo_internal_get(conn, pkgid_.c_str(), uid_, handle_);
 }
 
 }  // namespace database