Modify aul_app_event_destroy() function 67/289567/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 9 Mar 2023 23:12:15 +0000 (23:12 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 9 Mar 2023 23:13:34 +0000 (23:13 +0000)
If the caller thread ID is equal to the caller process ID,
the function releases the handle immediately. If it's not,
the function uses glib idler to avoid thread safe issues.

Change-Id: Id8272fb15be06459bab153932c4e1c0a9115fbf6
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
aul/api/aul_app_event.cc

index 9ff717f..1b1e94c 100644 (file)
@@ -17,6 +17,8 @@
 #include "aul/api/aul_app_event.h"
 
 #include <glib.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include <string>
 #include <utility>
@@ -137,6 +139,10 @@ extern "C" API int aul_app_event_destroy(aul_app_event_h app_event) {
   }
 
   auto* handle = static_cast<AppEventStub*>(app_event);
-  handle->Dispose();
+  if (getpid() == gettid())
+    delete handle;
+  else
+    handle->Dispose();
+
   return AUL_R_OK;
 }