From ba5621bd991eb43989c5b65e0cd4b90ffd129218 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 24 Feb 2022 11:56:32 +0900 Subject: [PATCH] Fix a bug about callback invocation The connection request will not be successful until the stub is the idle state. After sending the connection request to the stub, the proxy cannot get the rejected event or the disconnected event until the stub is the idle state. Because, when the port is appeared, the proxy removes the connection timer. This patch adjusts a position of the UnsetConnTimer() call to remove the connection timer properly. Change-Id: I4d0fb651fd30c77df9088580b38b171f1a98ca5d Signed-off-by: Hwankyu Jhun --- src/proxy-internal.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/proxy-internal.cc b/src/proxy-internal.cc index 098f742..faaa062 100644 --- a/src/proxy-internal.cc +++ b/src/proxy-internal.cc @@ -395,11 +395,11 @@ void Proxy::OnPortAppeared(const char* app_id, const char* port_name, int pid, return; } - proxy->UnsetConnTimer(); proxy->Cancel(); int ret = proxy->Connect(false); if (ret != RPC_PORT_ERROR_NONE) { + proxy->UnsetConnTimer(); proxy->listener_ = nullptr; if (ret == RPC_PORT_ERROR_PERMISSION_DENIED) listener->OnRejected(proxy->target_appid_, ret); @@ -673,6 +673,7 @@ gboolean Proxy::Client::OnSocketDisconnected(GIOChannel* channel, GIOCondition cond, gpointer user_data) { auto* proxy = static_cast(user_data); std::lock_guard lock(proxy->GetMutex()); + proxy->UnsetConnTimer(); auto* listener = proxy->listener_; if (listener == nullptr) { _E("Invalid context"); @@ -700,6 +701,7 @@ gboolean Proxy::Client::OnResponseReceived(GIOChannel* channel, GIOCondition cond, gpointer user_data) { auto* proxy = static_cast(user_data); std::lock_guard lock(proxy->GetMutex()); + proxy->UnsetConnTimer(); auto* listener = proxy->listener_; if (listener == nullptr) { _E("Invalid context"); -- 2.7.4