From: Hwankyu Jhun Date: Wed, 4 Jan 2023 03:46:37 +0000 (+0000) Subject: Modify connect method of proxy X-Git-Tag: accepted/tizen/unified/20230113.091214~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a65f6984cbf6d874f1413a021938b63cbddcde6;p=platform%2Fcore%2Fappfw%2Frpc-port.git Modify connect method of proxy The proxy is able to call the rpc_port_proxy_connect() function after calling the rpc_port_proxy_disconnect() function. Change-Id: Ib9cb6758b1792e4f3413164745b5c34819ef51ce Signed-off-by: Hwankyu Jhun --- diff --git a/src/proxy-internal.cc b/src/proxy-internal.cc index 518c436..8465ed2 100644 --- a/src/proxy-internal.cc +++ b/src/proxy-internal.cc @@ -197,7 +197,7 @@ int Proxy::Connect(std::string appid, std::string port_name, return RPC_PORT_ERROR_INVALID_PARAMETER; std::lock_guard lock(GetMutex()); - if (listener_ != nullptr) { + if (HasRequested()) { _D("Already requested"); return RPC_PORT_ERROR_INVALID_PARAMETER; } @@ -209,6 +209,7 @@ int Proxy::Connect(std::string appid, std::string port_name, main_port_.reset(); delegate_port_.reset(); + Cancel(); UnsetConnTimer(); int ret = Aul::PrepareStub(real_appid_, port_name_, rpc_port_get_target_uid()); @@ -231,12 +232,12 @@ int Proxy::ConnectSync(std::string appid, std::string port_name, if (listener == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER; - if (listener_ != nullptr) { - _W("Already requested"); + std::lock_guard lock(GetMutex()); + if (HasRequested()) { + _D("Already requested"); return RPC_PORT_ERROR_INVALID_PARAMETER; } - std::lock_guard lock(GetMutex()); listener_ = listener; target_appid_ = std::move(appid); port_name_ = std::move(port_name); @@ -801,5 +802,10 @@ void Proxy::DestroyWeakPtr(gpointer data) { delete ptr; } +bool Proxy::HasRequested() const { + return listener_ != nullptr && + (!main_port_ || !delegate_port_ || main_port_->GetFd() > 0); +} + } // namespace internal } // namespace rpc_port diff --git a/src/proxy-internal.hh b/src/proxy-internal.hh index 5003539..2cfef0d 100644 --- a/src/proxy-internal.hh +++ b/src/proxy-internal.hh @@ -130,6 +130,7 @@ class Proxy : public std::enable_shared_from_this { std::shared_ptr GetSharedPtr(); gpointer CreateWeakPtr(); static void DestroyWeakPtr(gpointer data); + bool HasRequested() const; private: std::string port_name_;