Ensure there is no attempts to close incorrect file descriptor 66/166666/2
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Thu, 11 Jan 2018 09:45:23 +0000 (10:45 +0100)
committerSylwester Nawrocki <s.nawrocki@samsung.com>
Thu, 11 Jan 2018 11:57:33 +0000 (12:57 +0100)
When destroying the camerasrc plugin instance there was incorrectly called
close() on fd_3aa0c and fd_3aa0 which was not initially set to an invalid
value and value of those fields was 0 at that time. This resulted to closing
stdin stream of the camera application, leading to errors when sending message
from the muse daemon like:

E/MUSED_CAMERA( 1332): muse_camera_dispatcher.c: __camera_dispatcher_send_msg(73)
> sending message[{ "api": 0, "api_class": 0, "ret": 0, "get_type": 5,
"get_index": -1, "handle": -219114416 }] failed. errno 25

Finally starting camera application was failing with en error:

D/TIZEN_N_CAMERA( 1273): camera.c: camera_create(2425) > cb info : 42
...
E/TIZEN_N_CAMERA( 1273): camera.c: _camera_client_wait_for_cb_return(529) > api 0 was TIMED OUT!
E/TIZEN_N_CAMERA( 1273): camera.c: _camera_client_wait_for_cb_return(542) > api 0 : error 0xffffffda
D/TIZEN_N_CAMERA( 1273): camera.c: _camera_client_callback_destroy(2167) > msg_recv thread[0xaad46b50] destroy

Fix this by initializing all camerasrc_handle_t::fd_* members to an invalid
value so there is no attempts to close an incorrect file descriptor.

Change-Id: I7bbce271f4b5eb535ce632e23390fea8298b7a3b
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
camerasrc/src/camerasrc.c

index a207065de18e8da87864db072bbb03b707cedecf..24003d7342b5ec260a78fafe2a9a4762963a4aa2 100644 (file)
@@ -1203,8 +1203,11 @@ static int _camerasrc_initialize_handle(camerasrc_handle_t *handle)
        handle->buffer_isp = NULL;
        handle->buffer_scc = NULL;
        handle->buffer_scp = NULL;
+       handle->fd_companion = -1;
        handle->fd_sensor = -1;
        handle->fd_isp = -1;
+       handle->fd_3aa0 = -1;
+       handle->fd_3aa0c = -1;
        handle->fd_3aa1 = -1;
        handle->fd_3aa1c = -1;
        handle->fd_scc = -1;