[Release version 0.2.67] Add error handling code in handle creation function 25/83325/1 accepted/tizen/common/20160811.145643 accepted/tizen/ivi/20160812.010627 accepted/tizen/mobile/20160812.010649 accepted/tizen/tv/20160812.010605 accepted/tizen/wearable/20160812.010530 submit/tizen/20160810.075454 submit/tizen/20160811.023523
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 10 Aug 2016 06:34:01 +0000 (15:34 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 10 Aug 2016 06:34:01 +0000 (15:34 +0900)
Change-Id: I6eac7491626504fab9efae7360fd3cbc121e9e44
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-camera.spec
src/camera.c

index 2bf72be..690d971 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.2.66
+Version:    0.2.67
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 402a45c..5e3bc83 100644 (file)
@@ -2153,7 +2153,8 @@ int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
 int camera_create(camera_device_e device, camera_h *camera)
 {
        int sock_fd = -1;
-       char *sndMsg;
+       char *send_msg = NULL;
+       int send_ret = 0;
        int ret = CAMERA_ERROR_NONE;
        int pid = 0;
        camera_cli_s *pc = NULL;
@@ -2183,14 +2184,28 @@ int camera_create(camera_device_e device, camera_h *camera)
 
        pid = getpid();
 
-       sndMsg = muse_core_msg_json_factory_new(api,
+       send_msg = muse_core_msg_json_factory_new(api,
                MUSE_TYPE_INT, "module", muse_module,
                MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
                MUSE_TYPE_INT, "pid", pid,
                0);
 
-       muse_core_ipc_send_msg(sock_fd, sndMsg);
-       muse_core_msg_json_factory_free(sndMsg);
+       if (!send_msg) {
+               LOGE("NULL msg");
+               ret = CAMERA_ERROR_OUT_OF_MEMORY;
+               goto ErrorExit;
+       }
+
+       send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
+
+       muse_core_msg_json_factory_free(send_msg);
+       send_msg = NULL;
+
+       if (send_ret < 0) {
+               LOGE("send msg failed %d", errno);
+               ret = CAMERA_ERROR_INVALID_OPERATION;
+               goto ErrorExit;
+       }
 
        pc = g_new0(camera_cli_s, 1);
        if (pc == NULL) {
@@ -2206,6 +2221,8 @@ int camera_create(camera_device_e device, camera_h *camera)
                goto ErrorExit;
        }
 
+       sock_fd = -1;
+
        LOGD("cb info : %d", pc->cb_info->fd);
 
        ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
@@ -2239,9 +2256,16 @@ ErrorExit:
        tbm_bufmgr_deinit(bufmgr);
        bufmgr = NULL;
 
+       if (sock_fd > -1) {
+               muse_core_connection_close(sock_fd);
+               sock_fd = -1;
+       }
+
        if (pc) {
-               _client_callback_destroy(pc->cb_info);
-               pc->cb_info = NULL;
+               if (pc->cb_info) {
+                       _client_callback_destroy(pc->cb_info);
+                       pc->cb_info = NULL;
+               }
                g_free(pc);
                pc = NULL;
        }