From 8222a5a4242f4efeb750d5a65c74b4732347e3da Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 2 Feb 2023 02:37:06 +0000 Subject: [PATCH] Move port existence check to the Watch method To make unblocking the main thread, the port existence check is moved to the Watch() method. If the proxy application calls the rpc_port_proxy_connect() function in the sub thread, the Aul::ExistPort() is called in the thread. Change-Id: Ie82e0527c56981337c1b241c8d2b090696a1b0de Signed-off-by: Hwankyu Jhun --- src/proxy-internal.cc | 7 ++++--- src/proxy-internal.hh | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/proxy-internal.cc b/src/proxy-internal.cc index 8465ed2..4a63e3a 100644 --- a/src/proxy-internal.cc +++ b/src/proxy-internal.cc @@ -298,6 +298,9 @@ int Proxy::Watch() { return -1; } + port_exist_ = Aul::ExistPort(real_appid_, port_name_, + rpc_port_get_target_uid()); + SetConnTimer(); SetIdler(); return 0; @@ -476,9 +479,7 @@ gboolean Proxy::OnIdle(gpointer user_data) { DestroyWeakPtr(proxy->idler_data_); proxy->idler_data_ = nullptr; - bool exist = Aul::ExistPort(proxy->real_appid_, proxy->port_name_, - rpc_port_get_target_uid()); - if (exist) { + if (proxy->port_exist_) { proxy->OnPortAppeared(proxy->real_appid_.c_str(), proxy->port_name_.c_str(), -1, proxy.get()); } else { diff --git a/src/proxy-internal.hh b/src/proxy-internal.hh index 2cfef0d..8da58ff 100644 --- a/src/proxy-internal.hh +++ b/src/proxy-internal.hh @@ -146,6 +146,7 @@ class Proxy : public std::enable_shared_from_this { gpointer conn_timer_data_ = nullptr; gpointer idler_data_ = nullptr; mutable std::recursive_mutex mutex_; + bool port_exist_ = false; }; } // namespace internal -- 2.7.4