Revert "Check current thread ID to destroy handle" 59/287259/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 26 Jan 2023 03:39:02 +0000 (03:39 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 26 Jan 2023 03:39:23 +0000 (03:39 +0000)
This reverts commit 2da1742b97e33d2b9c42d01104080721143d8b59.
When calling the event callback function, app developer releases the handle
in the callback function. It makes a crash issue.
Even if the destroy function is called in the main thread, the rpc-port library
doesn't release the handle immediately to prevent the issue.

Change-Id: I58a25d9e4c5f1f42065901dac8e6a30f22f898d2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/rpc-port.cc

index 88799b0..1a09c2c 100644 (file)
@@ -17,8 +17,6 @@
 #include <aul.h>
 #include <aul_rpc_port.h>
 #include <glib.h>
-#include <sys/types.h>
-#include <unistd.h>
 
 #include <atomic>
 #include <mutex>
@@ -303,13 +301,9 @@ RPC_API int rpc_port_proxy_destroy(rpc_port_proxy_h h) {
   }
 
   _W("rpc_port_proxy_destroy(%p)", proxy);
-  if (getpid() == gettid()) {
-    delete p;
-    return RPC_PORT_ERROR_NONE;
-  }
-
   proxy->SetDestroying(true);
   proxy->DisconnectPort();
+
   g_idle_add_full(G_PRIORITY_HIGH,
       [](gpointer data) -> gboolean {
         auto p = static_cast<std::shared_ptr<::ProxyExt>*>(data);
@@ -317,7 +311,6 @@ RPC_API int rpc_port_proxy_destroy(rpc_port_proxy_h h) {
         delete p;
         return G_SOURCE_REMOVE;
       }, h, nullptr);
-
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -446,11 +439,6 @@ RPC_API int rpc_port_stub_destroy(rpc_port_stub_h h) {
 
   p->SetDestroying(true);
   aul_rpc_port_usr_destroy(p->GetPortName().c_str(), rpc_port_get_target_uid());
-  if (getpid() == gettid()) {
-    delete p;
-    return RPC_PORT_ERROR_NONE;
-  }
-
   p->Ignore();
   g_idle_add_full(G_PRIORITY_HIGH,
       [](gpointer data) -> gboolean {
@@ -459,7 +447,6 @@ RPC_API int rpc_port_stub_destroy(rpc_port_stub_h h) {
         delete p;
         return G_SOURCE_REMOVE;
       }, h, nullptr);
-
   return RPC_PORT_ERROR_NONE;
 }