Set nullptr to the listener ptr 79/265479/2
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 20 Oct 2021 09:02:04 +0000 (18:02 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Wed, 20 Oct 2021 09:04:06 +0000 (09:04 +0000)
When the timed out error occurred, the listener ptr should be nullptr.
While calling the rejected callback function, the proxy process tries to
connect to the stub process.

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

index 91cb63e..098f742 100644 (file)
@@ -188,12 +188,12 @@ int Proxy::Connect(std::string appid, std::string port_name,
   if (listener == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
+  std::lock_guard<std::recursive_mutex> lock(GetMutex());
   if (listener_ != nullptr) {
     _D("Already requested");
     return RPC_PORT_ERROR_INVALID_PARAMETER;
   }
 
-  std::lock_guard<std::recursive_mutex> lock(GetMutex());
   listener_ = listener;
   target_appid_ = std::move(appid);
   port_name_ = std::move(port_name);
@@ -441,6 +441,7 @@ gboolean Proxy::OnTimedOut(gpointer user_data) {
     return G_SOURCE_REMOVE;
   }
 
+  proxy->listener_ = nullptr;
   listener->OnRejected(proxy->target_appid_, RPC_PORT_ERROR_IO_ERROR);
   return G_SOURCE_REMOVE;
 }