Call the 'disconnected callback' if the reply sent to the stub is null 85/218385/5
authorInkyun Kil <inkyun.kil@samsung.com>
Fri, 22 Nov 2019 00:46:50 +0000 (09:46 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Mon, 25 Nov 2019 00:03:44 +0000 (09:03 +0900)
The proxy should be checked if the port has been disconnected.
So, if the reply sent to the stub is null, should call the 'disconnected
callback' except 'G_IO_ERROR_CANCELLED'

Change-Id: Icdd80baad7cae62b5ba7886ff790435380fd4e65
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
src/fdbroker-internal.cc
src/fdbroker-internal.h
src/proxy-internal.cc
src/proxy-internal.h

index c77f2d5..5d8db42 100644 (file)
@@ -761,13 +761,22 @@ void FdBroker::OnResultReceived(GObject* source_object,
       res, &err);
   if (reply == nullptr) {
     LOGE("No reply. err(%s)", err ? err->message : "Unknown");
-    g_error_free(err);
-    return;
+    if (err && err->code == G_IO_ERROR_CANCELLED) {
+      g_error_free(err);
+      return;
+    }
   }
 
   FdBroker* broker = static_cast<FdBroker*>(user_data);
   IEventWatcher* watcher = broker->watcher_;
 
+  if (err) {
+    watcher->OnPortDisconnected(broker->watch_appid_, broker->watch_port_name_,
+        true);
+    g_error_free(err);
+    return;
+  }
+
   GVariant* reply_body = g_dbus_message_get_body(reply);
   if (reply_body == nullptr) {
     LOGE("g_dbus_message_get_body() is failed");
index ca489ab..be23530 100644 (file)
@@ -49,7 +49,8 @@ class FdBroker {
     virtual void OnPortConnected(const std::string& appid,
                                  const std::string& port_name) = 0;
     virtual void OnPortDisconnected(const std::string& appid,
-                                    const std::string& port_name) = 0;
+                                    const std::string& port_name,
+                                    bool cancel = false) = 0;
   };
 
   explicit FdBroker(bool mock = false) : mock_(mock) {}
index f09a493..b54f305 100644 (file)
@@ -141,10 +141,15 @@ void Proxy::OnPortConnected(const std::string& appid,
 }
 
 void Proxy::OnPortDisconnected(const std::string& appid,
-                               const std::string& port_name) {
+                               const std::string& port_name, bool cancel) {
   LOGW("[__OnPortDisconnected__] endporint(%s), port_name(%s)",
       appid.c_str(), port_name.c_str());
 
+  if (cancel) {
+    close(fds_[0]);
+    close(fds_[1]);
+  }
+
   IEventListener* listener = listener_;
   listener_ = nullptr;
   listener->OnDisconnected(appid);
index 75b30e2..a5046b0 100644 (file)
@@ -90,7 +90,8 @@ class Proxy : public FdBroker::IEventWatcher {
   void OnPortConnected(const std::string& appid,
                        const std::string& port_name) override;
   void OnPortDisconnected(const std::string& appid,
-                          const std::string& port_name) override;
+                          const std::string& port_name,
+                          bool cancel = false) override;
 
  private:
   std::string port_name_;