diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2016-08-10 15:34:01 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2016-08-10 15:34:01 +0900 |
commit | 61b32dedbdbfc5360e98afa7f42dcf32fd2b758c (patch) | |
tree | 83b91f4c607c7b52c274cc8d8eff4267e740ec4a /src/camera.c | |
parent | 3b9b49d27a189a7e20fa499b546f77296daba281 (diff) | |
download | camera-submit/tizen/20160810.075454.tar.gz camera-submit/tizen/20160810.075454.tar.bz2 camera-submit/tizen/20160810.075454.zip |
[Release version 0.2.67] Add error handling code in handle creation functionsubmit/tizen/20160811.023523submit/tizen/20160810.075454accepted/tizen/wearable/20160812.010530accepted/tizen/tv/20160812.010605accepted/tizen/mobile/20160812.010649accepted/tizen/ivi/20160812.010627accepted/tizen/common/20160811.145643
Change-Id: I6eac7491626504fab9efae7360fd3cbc121e9e44
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
Diffstat (limited to 'src/camera.c')
-rw-r--r-- | src/camera.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/camera.c b/src/camera.c index 402a45c..5e3bc83 100644 --- a/src/camera.c +++ b/src/camera.c @@ -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; } |