From: wn.jang Date: Thu, 28 Oct 2021 08:45:49 +0000 (+0900) Subject: Release memory when open connection is failed X-Git-Tag: submit/tizen/20211028.131731^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2292c36a6462296642e62e5b4cc74389029ab971;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Release memory when open connection is failed Change-Id: I3172ee394b75ea8a63e747f24dfc0797ee6a0fad --- diff --git a/server/vcd_server.c b/server/vcd_server.c index e80bc14..486b6cb 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1285,6 +1285,9 @@ int vcd_initialize(vce_request_callback_s *callback) ret = vc_db_initialize_for_daemon(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize DB : %d", ret); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return ret; } @@ -1299,17 +1302,26 @@ int vcd_initialize(vce_request_callback_s *callback) ret = vcd_engine_agent_init(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to engine agent initialize : result(%d)", ret); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return ret; } if (0 != vcd_recorder_create(__server_recorder_callback, __server_recorder_interrupt_callback)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to create recorder"); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return VCD_ERROR_OPERATION_FAILED; } /* Load engine */ if (0 != vcd_engine_agent_load_current_engine(callback)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to load current engine"); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return VCD_ERROR_OPERATION_FAILED; } @@ -1319,7 +1331,10 @@ int vcd_initialize(vce_request_callback_s *callback) // if (TRUE == __is_default_engine()) { /* Open dbus connection */ if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to open connection"); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return VCD_ERROR_OPERATION_FAILED; } // } @@ -1363,7 +1378,7 @@ bool vcd_finalize() } vcd_state_e state = vcd_config_get_service_state(); - if (VCD_STATE_READY != state) { + if (VCD_STATE_NONE != state && VCD_STATE_READY != state) { if (VCD_STATE_RECORDING == state) { vcd_recorder_stop(); } @@ -1396,8 +1411,10 @@ bool vcd_finalize() SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to finalize DB : %d", ret); } - vcd_config_set_service_state(VCD_STATE_NONE); - vcdc_send_service_state(VCD_STATE_NONE); + if (VCD_STATE_NONE != state) { + vcd_config_set_service_state(VCD_STATE_NONE); + vcdc_send_service_state(VCD_STATE_NONE); + } /* Open dbus connection */ if (0 != vcd_dbus_close_connection()) {