Fix the crash issue in OAL event loop 72/176572/3 accepted/tizen/unified/20180423.062836 submit/tizen/20180423.011216
authorHyuk Lee <hyuk0512.lee@samsung.com>
Fri, 20 Apr 2018 05:05:48 +0000 (14:05 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Mon, 23 Apr 2018 01:08:01 +0000 (10:08 +0900)
Change-Id: Id955d5e63429139ba2c7a869347956311c27b3d1
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
bt-oal/common/oal-event-dispatcher.c
bt-oal/oal-internal.h
bt-oal/oal-manager.c

index 965f16f..3fd6796 100644 (file)
@@ -40,11 +40,22 @@ typedef struct {
 
 static GMainContext *event_thread_context;
 static oal_event_callback event_handler_cb;
+GMainLoop *event_loop;
+
+void _bt_event_dispatcher_deinit()
+{
+       BT_DBG("+");
+       if (event_loop) {
+               BT_DBG("OAL event loop guit");
+               g_main_loop_quit(event_loop);
+       }
+
+       BT_DBG("-");
+}
 
 static gpointer __event_handler_loop(gpointer user_data)
 {
        gboolean ret = FALSE;
-       GMainLoop *event_loop;
 
        /* Set up the thread�s context and run it forever. */
        g_main_context_push_thread_default(event_thread_context);
@@ -57,7 +68,12 @@ static gpointer __event_handler_loop(gpointer user_data)
        } while (ret == FALSE);
 
        g_main_loop_run(event_loop);
-       g_main_loop_unref(event_loop);
+       BT_DBG("OAL event loop quited");
+
+       if (event_loop) {
+               g_main_loop_unref(event_loop);
+               event_loop = NULL;
+       }
 
        g_main_context_pop_thread_default(event_thread_context);
        g_main_context_unref(event_thread_context);
index aaf757a..e1fbfad 100755 (executable)
@@ -131,6 +131,7 @@ void send_event_no_trace(oal_event_t event, gpointer event_data, gsize len);
 #define _bt_dispatch_event send_event
 void send_event(oal_event_t event, gpointer event_data, gsize len);
 void _bt_event_dispatcher_init(oal_event_callback cb);
+void _bt_event_dispatcher_deinit(void);
 
 #ifdef __cplusplus
 }
index 83a4ab5..87b4869 100644 (file)
@@ -86,6 +86,8 @@ void oal_bt_deinit(void)
        BT_INFO("+");
        blued_api->cleanup();
        blued_api = NULL;
+       _bt_event_dispatcher_deinit();
+       sleep(1);
        unload_libs(NULL);
        BT_INFO("-");
 }