Avoid deadlock in focus watch callback handler in case of calling to unset the callba... 28/107128/1
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 26 Dec 2016 23:09:37 +0000 (08:09 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 26 Dec 2016 23:21:49 +0000 (08:21 +0900)
[Version] 0.10.76
[Profile] Common
[Issue Type] bug fix

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

index fe9cef3..16b8e2d 100644 (file)
@@ -1226,6 +1226,11 @@ static gboolean _focus_watch_callback_handler(gpointer d)
                        return FALSE;
                }
 
+               if (!g_focus_sound_handle[focus_index].is_used) {
+                       debug_warning("unsetting watch calllback has been already requested");
+                       goto SKIP_CB_AND_RET;
+               }
+
                debug_msg("lock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
                g_mutex_lock(&g_focus_sound_handle[focus_index].focus_lock);
 
@@ -1245,6 +1250,7 @@ static gboolean _focus_watch_callback_handler(gpointer d)
                        }
                }
 
+SKIP_CB_AND_RET:
 #ifdef CONFIG_ENABLE_RETCB
                {
                        int rett = 0;
@@ -1269,12 +1275,13 @@ static gboolean _focus_watch_callback_handler(gpointer d)
 #endif
        }
 
-       debug_msg("unlock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
-       g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
+       if (g_focus_sound_handle[focus_index].is_used) {
+               debug_msg("unlock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
+               g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
+       }
 
        debug_fleave();
 
-
        return TRUE;
 }
 
@@ -1899,6 +1906,8 @@ int mm_sound_client_unset_focus_watch_callback(int id)
 
        g_mutex_lock(&g_focus_sound_handle[index].focus_lock);
 
+       g_focus_sound_handle[index].is_used = false;
+
        ret = mm_sound_proxy_unset_focus_watch_callback(g_focus_sound_handle[index].focus_tid, g_focus_sound_handle[index].handle, g_focus_sound_handle[index].is_for_session);
 
        if (ret == MM_ERROR_NONE)
@@ -1913,7 +1922,6 @@ int mm_sound_client_unset_focus_watch_callback(int id)
        g_focus_sound_handle[index].focus_fd = 0;
        g_focus_sound_handle[index].focus_tid = 0;
        g_focus_sound_handle[index].handle = 0;
-       g_focus_sound_handle[index].is_used = false;
 cleanup:
        MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
        debug_fleave();
index c82dad7..2afccc6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.75
+Version:    0.10.76
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0