Fix wrong implementation of component port 20/252920/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 3 Feb 2021 06:00:34 +0000 (15:00 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 3 Feb 2021 06:00:34 +0000 (15:00 +0900)
Change-Id: Ibab4784ff59847ffae94e230460c2abfbafa7bbb
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
component_based/port/server.cc

index e8f88091006f1678db4b4ba954894015e2fdbf8b..13078bf1ef12a5b050c4dba96a3703fb501c61c4 100644 (file)
@@ -58,7 +58,7 @@ Server::~Server() {
   }
 
   if (source_) {
-    if (g_source_is_destroyed(source_))
+    if (!g_source_is_destroyed(source_))
       g_source_destroy(source_);
   }
 
@@ -128,8 +128,16 @@ int Server::CheckPrivilege(int fd) {
 }
 
 gboolean Server::GIOFunc(GIOChannel* source, GIOCondition cond, gpointer data) {
+  if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+    _E("Error condition(%d)", static_cast<int>(cond));
+    return G_SOURCE_REMOVE;
+  }
+
   auto* handle = static_cast<Server*>(data);
   auto client = std::unique_ptr<Client>(handle->Accept());
+  if (client.get() == nullptr)
+    return G_SOURCE_CONTINUE;
+
   int ret = handle->CheckPrivilege(client->GetFd());
   if (ret != 0) {
     _E("Request is denied");