Move port existence check to the Watch method
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 03:54:42 +0000 (03:54 +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 518c436ccaa3fb343e16062dfe9babd51950c899..804f69011d3b4a044773711928b32955a10d9381 100644 (file)
@@ -297,6 +297,9 @@ int Proxy::Watch() {
     return -1;
   }
 
+  port_exist_ = Aul::ExistPort(real_appid_, port_name_,
+      rpc_port_get_target_uid());
+
   SetConnTimer();
   SetIdler();
   return 0;
@@ -475,9 +478,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 5003539e2bc7354f7f683f3c2399c81d239430de..c22aafcca55c8829bd8816600fc73eb1a1a58636 100644 (file)
@@ -145,6 +145,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