Fix lock up issue when no response from muse-server 60/169860/1
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 7 Feb 2018 11:55:45 +0000 (20:55 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 12 Feb 2018 01:38:32 +0000 (10:38 +0900)
- "camera_create" is not returned if no msg is received from muse-server after requested,
  so, we should close fd to receive msg from muse-server, then we can return error properly.

[Version] 0.4.4
[Profile] Common
[Issue Type] Bug fix
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-4.0-unified_20180207.1]

Change-Id: Ifc73dfc61bf1ff66db8f41a36340042c55156557
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-camera.spec
src/camera.c

index ae1196c..47133e2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.4.3
+Version:    0.4.4
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 9dbf13f..59825aa 100644 (file)
@@ -1844,7 +1844,7 @@ static void *_camera_msg_recv_func(gpointer data)
                return NULL;
        }
 
-       LOGD("start");
+       LOGD("start - fd : %d", cb_info->fd);
 
        single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
        if (!single_msg) {
@@ -1937,8 +1937,15 @@ static void *_camera_msg_recv_func(gpointer data)
        LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
 
        if (!cb_info->is_server_connected) {
+               char *error_msg = NULL;
+
+               if (cb_info->fd < 0) {
+                       LOGE("fd is closed in client side");
+                       goto CB_HANDLER_EXIT;
+               }
+
                /* send error msg for server disconnection */
-               char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
+               error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
                        MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
                        MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
                        NULL);
@@ -2458,6 +2465,16 @@ ErrorExit:
 
        if (pc) {
                if (pc->cb_info) {
+                       int temp_fd = pc->cb_info->fd;
+
+                       /* pc->cb_info->fd should be closed,
+                          because g_thread_join for msg_recv_thread is not returned
+                          in _camera_client_callback_destroy. */
+                       if (temp_fd > -1) {
+                               pc->cb_info->fd = -1;
+                               muse_client_close(temp_fd);
+                       }
+
                        _camera_client_callback_destroy(pc->cb_info);
                        pc->cb_info = NULL;
                }