Enhance error handling in case of failure in focus_init_context() 41/192641/2 accepted/tizen/unified/20181108.074556 submit/tizen/20181107.105006
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 7 Nov 2018 07:42:04 +0000 (16:42 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 7 Nov 2018 10:12:02 +0000 (19:12 +0900)
operations of quitting mainloop and joining focus thread are added to error handling codes.
timeout for waiting run state of mainloop is also changed to 2.5 sec.

[Version] 0.12.29
[Issue Type] Enhancement

Change-Id: Ide47c174b531395d69a1aa9f45a4b381f4d505af
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
mm_sound_focus_private.c
packaging/libmm-sound.spec

index c781840330f4ebb2529f9a93bd35e5a4728a60ee..98b06a7aca15a43176ad514822ff727f45c276a0 100644 (file)
@@ -537,7 +537,7 @@ int focus_watch_find_index_by_handle(int handle)
        return -1;
 }
 
-#define LOOP_RUNNING_WAIT_TIME_MS 200
+#define LOOP_RUNNING_WAIT_TIME_MS 2500
 int focus_init_context(int index)
 {
        int ret = MM_ERROR_NONE;
@@ -552,7 +552,7 @@ int focus_init_context(int index)
 
        focus_context = g_main_context_new();
        g_focus_sound_handle[index].focus_loop = g_main_loop_new(focus_context, FALSE);
-       g_main_context_unref(focus_context);
+       g_main_context_unref(focus_context); /* FYI, this context resource will be released when calling g_main_loop_unref() */
        if (g_focus_sound_handle[index].focus_loop == NULL) {
                debug_error("could not create mainloop..");
                goto ERROR;
@@ -580,6 +580,13 @@ int focus_init_context(int index)
 
 ERROR:
        if (g_focus_sound_handle[index].focus_loop) {
+               if (g_focus_sound_handle[index].focus_cb_thread) {
+                       g_main_loop_quit(g_focus_sound_handle[index].focus_loop);
+                       g_thread_join(g_focus_sound_handle[index].focus_cb_thread);
+                       debug_warning("after thread join, thread[%p], mainloop[%p] for index(%d)",
+                                       g_focus_sound_handle[index].focus_cb_thread, g_focus_sound_handle[index].focus_loop, index);
+                       g_focus_sound_handle[index].focus_cb_thread = NULL;
+               }
                g_main_loop_unref(g_focus_sound_handle[index].focus_loop);
                g_focus_sound_handle[index].focus_loop = NULL;
        }
index 43d0c158a408855072a9188fa21053aba988fca5..8d9a1b821663c2328951ac98e8868e8d289d4585 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.12.28
+Version:    0.12.29
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0