Increase timeout value in case of db write request 60/276860/5
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 27 Jun 2022 06:40:28 +0000 (15:40 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 27 Jun 2022 09:10:25 +0000 (18:10 +0900)
Change-Id: I39718d869d7941db9de3af62d02481cd60bf6a6f
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/client/pkginfo_client.cc
src/common/socket/client_socket.cc
src/common/socket/client_socket.hh

index f552f3c..dd1bcbd 100644 (file)
@@ -65,7 +65,7 @@ bool PkgInfoClient::SendRequest() {
   LOG(WARNING) << "Try to send request, Request type: "
       << pkgmgr_common::ReqTypeToString(req_type_);
 
-  if (!socket_->Connect()) {
+  if (!socket_->Connect(req_type_)) {
     LOG(ERROR) << "Failed to connect client socket, try to direct access";
     is_offline_ = true;
     return RequestHandlerDirectAccess(p.GetRaw());
index a8c75f7..3eda1e5 100644 (file)
 
 #include "pkgmgrinfo_debug.h"
 
+namespace {
+
+bool IsDBWriteRequest(pkgmgr_common::ReqType req_type) {
+  if (req_type != pkgmgr_common::ReqType::SET_PKG_INFO &&
+      req_type != pkgmgr_common::ReqType::SET_CERT_INFO)
+    return false;
+
+  return true;
+}
+
+}
+
 namespace pkgmgr_common {
 namespace socket {
 
@@ -51,11 +63,11 @@ void ClientSocket::SetTimeout(int timeout_msec) {
         << ", errno: " << errno;
 }
 
-bool ClientSocket::Connect() {
+bool ClientSocket::Connect(ReqType req_type) {
   if (Create() < 0)
     return false;
 
-  SetTimeout(5000);
+  SetTimeout(IsDBWriteRequest(req_type) ? 60 * 1000 : 5 * 1000);
 
   int retry_cnt = 3;
   do {
index 6071de3..a08113b 100644 (file)
@@ -18,6 +18,7 @@
 #define COMMON_CLIENT_SOCKET_HH_
 
 #include "abstract_socket.hh"
+#include "request_type.hh"
 
 namespace pkgmgr_common {
 namespace socket {
@@ -25,7 +26,7 @@ namespace socket {
 class EXPORT_API ClientSocket: public AbstractSocket {
  public:
   ClientSocket(std::string path);
-  bool Connect();
+  bool Connect(ReqType req_type);
 
  private:
   int TryConnection();