Move port existence check to the Watch method 44/287644/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 2 Feb 2023 02:37:06 +0000 (02:37 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 2 Feb 2023 02:40:06 +0000 (02:40 +0000)
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 <h.jhun@samsung.com>
src/proxy-internal.cc
src/proxy-internal.hh

index 8465ed2..4a63e3a 100644 (file)
@@ -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 {
index 2cfef0d..8da58ff 100644 (file)
@@ -146,6 +146,7 @@ class Proxy : public std::enable_shared_from_this<Proxy> {
   gpointer conn_timer_data_ = nullptr;
   gpointer idler_data_ = nullptr;
   mutable std::recursive_mutex mutex_;
+  bool port_exist_ = false;
 };
 
 }  // namespace internal