Change type of pid
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 9 Mar 2021 01:51:05 +0000 (10:51 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 9 Mar 2021 01:51:05 +0000 (10:51 +0900)
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/database/abstract_db_handler.hh
src/common/database/db_handle_provider.cc
src/common/database/db_handle_provider.hh
src/common/request_handler/abstract_request_handler.cc
src/common/request_handler/abstract_request_handler.hh
src/common/socket/abstract_socket.cc
src/common/socket/abstract_socket.hh
src/server/pkg_request.cc
src/server/pkg_request.hh

index 3b9c1b4..8b0d292 100644 (file)
@@ -44,7 +44,7 @@ class EXPORT_API AbstractDBHandler {
     OPERATION_TYPE_WRITE
   };
 
-  AbstractDBHandler(uid_t uid, int pid);
+  AbstractDBHandler(uid_t uid, pid_t pid);
   virtual ~AbstractDBHandler();
   virtual int Execute() = 0;
   void SetLocale(const std::string& locale);
@@ -63,7 +63,7 @@ class EXPORT_API AbstractDBHandler {
   DBType db_type_ = DB_TYPE_NONE;
   OperationType op_type_ = OPERATION_TYPE_NONE;
   uid_t uid_;
-  int pid_;
+  pid_t pid_;
   std::string locale_;
   std::vector<sqlite3*> db_handle_list_;
 };
index d1eca7a..5ecb086 100644 (file)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <sys/types.h>
+
 #include <tzplatform_config.h>
 
 #include "db_handle_provider.hh"
@@ -90,11 +92,11 @@ DBHandleProvider& DBHandleProvider::GetInst(uid_t uid) {
   return *prov;
 }
 
-std::vector<std::string> DBHandleProvider::GetParserDBPath(int pid) {
+std::vector<std::string> DBHandleProvider::GetParserDBPath(pid_t pid) {
   std::unique_lock<std::mutex> u(lock_);
   std::vector<std::string> db_path_list;
   bool is_file_access = is_memory_;
-  std::vector<int>::iterator it = std::find(pid_list_.begin(),
+  std::vector<pid_t>::iterator it = std::find(pid_list_.begin(),
       pid_list_.end(), pid);
   if (it == pid_list_.end())
     is_file_access = true;
@@ -111,10 +113,10 @@ std::vector<std::string> DBHandleProvider::GetParserDBPath(int pid) {
   return db_path_list;
 }
 
-std::string DBHandleProvider::GetCertDBPath(int pid) {
+std::string DBHandleProvider::GetCertDBPath(pid_t pid) {
   std::unique_lock<std::mutex> u(lock_);
   bool is_file_access = is_memory_;
-  std::vector<int>::iterator it = std::find(pid_list_.begin(),
+  std::vector<pid_t>::iterator it = std::find(pid_list_.begin(),
       pid_list_.end(), pid);
   if (it == pid_list_.end())
     is_file_access = true;
@@ -159,7 +161,7 @@ sqlite3* DBHandleProvider::GetMemoryDBHandle(const std::string& filedb_path,
   return memorydb;
 }
 
-void DBHandleProvider::SetMemoryMode(int pid, bool flag) {
+void DBHandleProvider::SetMemoryMode(pid_t pid, bool flag) {
   std::unique_lock<std::mutex> u(lock_);
   if (is_memory_ == flag)
     return;
@@ -182,7 +184,7 @@ void DBHandleProvider::SetMemoryMode(int pid, bool flag) {
     parser_memory_db_handle_.reset(nullptr);
     cert_memory_db_handle_.reset(nullptr);
     global_parser_memory_db_handle_.reset(nullptr);
-    std::vector<int>::iterator it =
+    std::vector<pid_t>::iterator it =
         std::find(pid_list_.begin(), pid_list_.end(), pid);
     if (it != pid_list_.end())
       pid_list_.erase(it);
index 5c673c4..cf74af0 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <sqlite3.h>
 #include <stdlib.h>
+#include <sys/types.h>
 
 #include <string>
 #include <memory>
@@ -60,7 +61,7 @@ class EXPORT_API DBHandleProvider {
   std::string cert_memory_db_path_;
   std::string cert_file_db_path_;
   static bool is_memory_;
-  std::vector<int> pid_list_;
+  std::vector<pid_t> pid_list_;
   std::mutex lock_;
 };
 
index 798130d..63d7e63 100644 (file)
 namespace pkgmgr_server {
 namespace request_handler {
 
-void AbstractRequestHandler::SetPID(int pid) {
+void AbstractRequestHandler::SetPID(pid_t pid) {
   pid_ = pid;
 }
 
-int AbstractRequestHandler::GetPID() {
+pid_t AbstractRequestHandler::GetPID() {
   return pid_;
 }
 
index 0ddc369..c60aaba 100644 (file)
@@ -6,6 +6,9 @@
 #define SERVER_ABSTRACT_REQUEST_HANDLER_HH_
 
 #include <string>
+
+#include <sys/types.h>
+
 #include <parcel.hh>
 
 namespace pkgmgr_server {
@@ -21,13 +24,13 @@ class EXPORT_API AbstractRequestHandler {
   virtual bool HandleRequest(unsigned char* data, int size, std::string locale) = 0;
 
   virtual std::vector<uint8_t> GetResult() = 0;
-  void SetPID(int pid);
+  void SetPID(pid_t pid);
 
  protected:
-  int GetPID();
+  pid_t GetPID();
 
  private:
-  int pid_;
+  pid_t pid_;
 };
 
 }  // namespace request_handler
index e2e2f8f..a5e8225 100644 (file)
@@ -89,7 +89,7 @@ int AbstractSocket::GetFd() { return fd_; }
 
 std::string AbstractSocket::GetPath() { return path_; }
 
-int AbstractSocket::GetPID() {
+pid_t AbstractSocket::GetPID() {
   int r;
   struct ucred cred;
   socklen_t len;
index 1220b86..bed1ec7 100644 (file)
@@ -18,6 +18,7 @@
 #define COMMON_ABSTRACT_SOCKET_HH_
 
 #include <sys/un.h>
+#include <sys/types.h>
 
 #include <string>
 
@@ -40,7 +41,7 @@ class EXPORT_API AbstractSocket {
 
   int GetFd();
   std::string GetPath();
-  int GetPID();
+  pid_t GetPID();
 
  protected:
   void SetOption();
index 5203d5e..7cfa918 100644 (file)
@@ -34,7 +34,7 @@ unsigned char* PkgRequest::GetData() { return data_; }
 
 int PkgRequest::GetSize() { return data_size_; }
 
-int PkgRequest::GetSenderPID() {
+pid_t PkgRequest::GetSenderPID() {
   return socket_->GetPID();
 }
 
index 2036e54..afe5ab5 100644 (file)
@@ -18,6 +18,9 @@
 #define SERVER_PKG_REQUEST_HH_
 
 #include <memory>
+
+#include <sys/types.h>
+
 #include "data_socket.hh"
 #include "request_type.hh"
 
@@ -33,7 +36,7 @@ class EXPORT_API PkgRequest {
   ~PkgRequest();
   unsigned char* GetData();
   int GetSize();
-  int GetSenderPID();
+  pid_t GetSenderPID();
   pkgmgr_common::ReqType GetRequestType();
   bool ReceiveData();
   bool SendData(unsigned char* data, int size);