Fix a bug about callback invocation 38/271638/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 24 Feb 2022 02:56:32 +0000 (11:56 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 24 Feb 2022 02:56:32 +0000 (11:56 +0900)
The connection request will not be successful until the stub is the idle state.
After sending the connection request to the stub, the proxy cannot get
the rejected event or the disconnected event until the stub is the idle
state. Because, when the port is appeared, the proxy removes the connection timer.
This patch adjusts a position of the UnsetConnTimer() call to remove
the connection timer properly.

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

index 098f742..faaa062 100644 (file)
@@ -395,11 +395,11 @@ void Proxy::OnPortAppeared(const char* app_id, const char* port_name, int pid,
     return;
   }
 
-  proxy->UnsetConnTimer();
   proxy->Cancel();
 
   int ret = proxy->Connect(false);
   if (ret != RPC_PORT_ERROR_NONE) {
+    proxy->UnsetConnTimer();
     proxy->listener_ = nullptr;
     if (ret == RPC_PORT_ERROR_PERMISSION_DENIED)
       listener->OnRejected(proxy->target_appid_, ret);
@@ -673,6 +673,7 @@ gboolean Proxy::Client::OnSocketDisconnected(GIOChannel* channel,
     GIOCondition cond, gpointer user_data) {
   auto* proxy = static_cast<Proxy*>(user_data);
   std::lock_guard<std::recursive_mutex> lock(proxy->GetMutex());
+  proxy->UnsetConnTimer();
   auto* listener = proxy->listener_;
   if (listener == nullptr) {
     _E("Invalid context");
@@ -700,6 +701,7 @@ gboolean Proxy::Client::OnResponseReceived(GIOChannel* channel,
     GIOCondition cond, gpointer user_data) {
   auto* proxy = static_cast<Proxy*>(user_data);
   std::lock_guard<std::recursive_mutex> lock(proxy->GetMutex());
+  proxy->UnsetConnTimer();
   auto* listener = proxy->listener_;
   if (listener == nullptr) {
     _E("Invalid context");