From: Ilho Kim Date: Mon, 27 Jun 2022 06:40:28 +0000 (+0900) Subject: Increase timeout value in case of db write request X-Git-Tag: submit/tizen/20220627.091746~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a216031df43cc67de85b72d306b9ca0c1c9c373f;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git Increase timeout value in case of db write request Change-Id: I39718d869d7941db9de3af62d02481cd60bf6a6f Signed-off-by: Ilho Kim --- diff --git a/src/client/pkginfo_client.cc b/src/client/pkginfo_client.cc index f552f3c0..dd1bcbda 100644 --- a/src/client/pkginfo_client.cc +++ b/src/client/pkginfo_client.cc @@ -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()); diff --git a/src/common/socket/client_socket.cc b/src/common/socket/client_socket.cc index a8c75f79..3eda1e54 100644 --- a/src/common/socket/client_socket.cc +++ b/src/common/socket/client_socket.cc @@ -27,6 +27,18 @@ #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 { diff --git a/src/common/socket/client_socket.hh b/src/common/socket/client_socket.hh index 6071de3e..a08113be 100644 --- a/src/common/socket/client_socket.hh +++ b/src/common/socket/client_socket.hh @@ -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();