Modify exception handling 28/182928/4
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 28 Jun 2018 23:13:24 +0000 (08:13 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Fri, 29 Jun 2018 00:18:15 +0000 (00:18 +0000)
If Send() method returns EILLEGALACCESS, OnRejected() function
is invoked.

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

index d0b53ee..2c183a3 100644 (file)
@@ -33,6 +33,7 @@
 
 #define LOG_TAG "RPC_PORT"
 
+#define EILLEGALACCESS 127
 
 #define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
 #define DBUS_PATH_DBUS "/org/freedesktop/DBus"
@@ -100,6 +101,8 @@ FdBroker::DBusMock& FdBroker::DBusMock::GetInst() {
 
 int FdBroker::DBusMock::Send(const std::string& sender,
                              const std::string& port, int fds[2]) {
+  if (port == "wrong_port")
+    return -EILLEGALACCESS;
   if (ports_.find(port) == ports_.end())
     return -1;
 
@@ -295,7 +298,7 @@ int FdBroker::Send(const std::string& target_appid,
     LOGE("Access Denied[sender_appid : %s]", sender_appid);
     g_object_unref(msg);
     g_object_unref(reply);
-    return -1;
+    return -EILLEGALACCESS;
   }
 
   LOGD("[Reply : %d]", ret);
index 2b6c6c6..4830f42 100644 (file)
@@ -102,10 +102,13 @@ void Proxy::OnPortAppeared(const std::string& appid,
 
   int fds[2] = { 0, };
   int r = fd_broker_.Send(appid, port_name, &fds);
-  if (r <= 0 || fds[0] <= 0 || fds[1] <= 0) {
+  if (r <= 0) {
     IEventListener* listener = listener_;
     listener_ = nullptr;
-    listener->OnRejected(appid);
+    if (r == -EILLEGALACCESS)
+      listener->OnRejected(appid);
+    else
+      listener->OnDisconnected(appid);
     return;
   }
 
@@ -117,7 +120,8 @@ void Proxy::OnPortAppeared(const std::string& appid,
 
 void Proxy::OnPortVanished(const std::string& appid,
                            const std::string& port_name) {
-  LOGD("endpoint(%s), port_name(%s)", appid.c_str(), port_name.c_str());
+  LOGW("[__OnPortVanished__] endpoint(%s), port_name(%s)",
+      appid.c_str(), port_name.c_str());
 }
 
 int Proxy::Connect(const std::string appid, const std::string& port_name,