Fix OnResultReceived() of proxy 81/299181/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 21 Sep 2023 07:27:20 +0000 (16:27 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 21 Sep 2023 07:27:20 +0000 (16:27 +0900)
This patch adds printing logs for debugging.
Before calling the OnConnected(), the rpc-port library checks whether
main and delegate ports are nullptrs or not.

Change-Id: Ief9fb0da872058b8451165a0492f73509bdc1ce0
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/proxy-internal.cc

index 4cf650d..c35ff8c 100644 (file)
@@ -787,21 +787,28 @@ gboolean Proxy::Client::OnResponseReceived(GIOChannel* channel,
   client->SetNonblock();
   int client_fd = client->RemoveFd();
   if (is_delegate) {
+    _W("[DELEGATE] Result received");
     proxy->fds_[1] = client_fd;
     proxy->delegate_port_.reset(
         new ProxyPort(proxy, proxy->fds_[1], proxy->target_appid_));
-    DebugPort::AddSession(proxy->port_name_, proxy->target_appid_,
-        proxy->fds_[0], proxy->fds_[1]);
-    listener->OnConnected(proxy->target_appid_, proxy->main_port_.get());
-    _W("target_appid(%s), port_name(%s), main_fd(%d), delegate_fd(%d)",
-        proxy->target_appid_.c_str(), proxy->port_name_.c_str(),
-        proxy->fds_[0], proxy->fds_[1]);
   } else {
+    _W("[MAIN] Result received");
     proxy->fds_[0] = client_fd;
     proxy->main_port_.reset(
         new ProxyPort(proxy, proxy->fds_[0], proxy->target_appid_, false));
   }
 
+  if (proxy->main_port_.get() != nullptr &&
+      proxy->delegate_port_.get() != nullptr) {
+    _W("target_appid(%s), port_name(%s), main_fd(%d), delegate_fd(%d)",
+        proxy->target_appid_.c_str(), proxy->port_name_.c_str(),
+        proxy->fds_[0], proxy->fds_[1]);
+
+    DebugPort::AddSession(proxy->port_name_, proxy->target_appid_,
+        proxy->fds_[0], proxy->fds_[1]);
+    listener->OnConnected(proxy->target_appid_, proxy->main_port_.get());
+  }
+
   return G_SOURCE_REMOVE;
 }