[Release version 0.2.30] Add error handling code in handle creation function 17/83317/1 accepted/tizen/common/20160811.145645 accepted/tizen/ivi/20160812.010628 accepted/tizen/mobile/20160812.010651 accepted/tizen/tv/20160812.010606 accepted/tizen/wearable/20160812.010532 submit/tizen/20160810.075454 submit/tizen/20160811.023523
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 10 Aug 2016 05:59:09 +0000 (14:59 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 10 Aug 2016 05:59:09 +0000 (14:59 +0900)
Change-Id: Ibf0903b071c645255945e4b9a7470f830659a51d
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-recorder.spec
src/recorder.c

index 47ae6c2..4c07f0f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-recorder
 Summary:    A Recorder API
-Version:    0.2.29
+Version:    0.2.30
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 56d1731..36ef60f 100644 (file)
@@ -1162,6 +1162,7 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
        int ret = RECORDER_ERROR_NONE;
        int destroy_ret = RECORDER_ERROR_NONE;
        int sock_fd = -1;
+       int send_ret = 0;
        char *send_msg = NULL;
        char *root_directory = NULL;
        intptr_t camera_handle = 0;
@@ -1218,15 +1219,23 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
        }
 
        if (!send_msg) {
-               LOGE("failed to create msg");
+               LOGE("NULL msg");
                ret = RECORDER_ERROR_OUT_OF_MEMORY;
                goto _ERR_RECORDER_EXIT;
        }
 
        LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
 
-       muse_core_ipc_send_msg(sock_fd, send_msg);
+       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 = RECORDER_ERROR_INVALID_OPERATION;
+               goto _ERR_RECORDER_EXIT;
+       }
 
        pc->cb_info = _recorder_client_callback_new(sock_fd);
        if (pc->cb_info == NULL) {
@@ -1234,6 +1243,8 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
                goto _ERR_RECORDER_EXIT;
        }
 
+       sock_fd = -1;
+
        ret = _recorder_client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CB_TIMEOUT);
        if (ret != RECORDER_ERROR_NONE) {
                LOGE("API_CREATE failed 0x%x", ret);
@@ -1293,6 +1304,11 @@ _ERR_RECORDER_EXIT:
                root_directory = NULL;
        }
 
+       if (sock_fd > -1) {
+               muse_core_connection_close(sock_fd);
+               sock_fd = -1;
+       }
+
        if (pc) {
                if (pc->cb_info) {
                        _recorder_client_callback_destroy(pc->cb_info);