From: Hwankyu Jhun Date: Wed, 27 Nov 2024 00:16:06 +0000 (+0900) Subject: Release client instances X-Git-Tag: accepted/tizen/unified/20241205.060747~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfad04c693e9675d2421b46baa9164e7079d55d7;p=platform%2Fcore%2Fappfw%2Frpc-port.git Release client instances When creating the client channel is failed, we should release client instances. Change-Id: I7d5c564cbc3ac0d6634d51d9e235187bde44aa84 Signed-off-by: Hwankyu Jhun --- diff --git a/src/rpc-port/proxy-internal.cc b/src/rpc-port/proxy-internal.cc index 809ab84..c36d785 100644 --- a/src/rpc-port/proxy-internal.cc +++ b/src/rpc-port/proxy-internal.cc @@ -131,15 +131,27 @@ int Proxy::Connect(bool sync) { ret = CreateClientChannel(instance, kPortTypeMainWrite, sync, &main_client_[1]); - if (ret != RPC_PORT_ERROR_NONE) return ret; + if (ret != RPC_PORT_ERROR_NONE) { + main_client_[0].reset(); + return ret; + } ret = CreateClientChannel(instance, kPortTypeDelegateRead, sync, &delegate_client_[0]); - if (ret != RPC_PORT_ERROR_NONE) return ret; + if (ret != RPC_PORT_ERROR_NONE) { + main_client_[1].reset(); + main_client_[0].reset(); + return ret; + } ret = CreateClientChannel(instance, kPortTypeDelegateWrite, sync, &delegate_client_[1]); - if (ret != RPC_PORT_ERROR_NONE) return ret; + if (ret != RPC_PORT_ERROR_NONE) { + delegate_client_[0].reset(); + main_client_[1].reset(); + main_client_[0].reset(); + return ret; + } auto peer_cred = std::unique_ptr(PeerCred::Get(main_client_[0]->GetFd()));