Fix a timing issue related to disconnected event 96/318296/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 26 Sep 2024 11:37:49 +0000 (20:37 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 26 Sep 2024 11:37:49 +0000 (20:37 +0900)
The port instance should be released after calling the disconnected
event callback.

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

index 98baae563ca795ac1fa14829e9c6fb86823d73a2..2925d489ea6d717930472d81f1f939844ae76ad9 100644 (file)
@@ -517,13 +517,12 @@ void Proxy::OnDataReceived(int fd) {
   if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) {
     _W("Socket was disconnected by stub. fd(%d)", fd);
     listener_ = nullptr;
+    listener->OnDisconnected(target_appid_);
+    delegate_port_.reset();
     if (main_port_.get() != nullptr) {
       DebugPort::RemoveSession(fd);
       main_port_.reset();
     }
-
-    delegate_port_.reset();
-    listener->OnDisconnected(target_appid_);
     return;
   }