From 36964257dd641444f132067a7b60ab1431dc81ec Mon Sep 17 00:00:00 2001 From: Sooyeon Kim Date: Wed, 27 Mar 2019 11:26:24 +0000 Subject: [PATCH 01/16] Revert "Remove far field package" This reverts commit 025197c2bd58336a3be24fefe01cfae3923c320c. Change-Id: I38bb9b3df563d30c37ac96d46f691a5368418f52 --- CMakeLists.txt | 3 +-- packaging/voice-control.spec | 2 +- server/vcd_recorder.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a6f5ed..ffeca96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,8 +46,7 @@ INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED aul capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland - capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi -#farfield-voice-api + capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi farfield-voice-api ) ELSE() pkg_check_modules(pkgs REQUIRED diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 5eeb57e..1115948 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -36,7 +36,7 @@ BuildRequires: pkgconfig(pkgmgr-installer) BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-network-bluetooth-tv) BuildRequires: pkgconfig(msfapi) -#BuildRequires: pkgconfig(farfield-voice-api) +BuildRequires: pkgconfig(farfield-voice-api) %endif BuildRequires: pkgconfig(vconf) BuildRequires: cmake diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 8f69004..7a85e9a 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -17,7 +17,7 @@ #ifdef TV_PRODUCT #define TV_BT_MODE #define TV_MSF_WIFI_MODE -//#define TV_FFV_MODE +#define TV_FFV_MODE #endif #include @@ -226,6 +226,16 @@ static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void #ifdef TV_FFV_MODE static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_data) { + if (0 == g_buffer_count || 0 == g_buffer_count % 50) { + SLOG(LOG_INFO, TAG_VCD, "[Recorder INFO] farfield audio function callback is invoked"); + + if (100000 == g_buffer_count) { + g_buffer_count = 0; + } + } + + g_buffer_count++; + if (0 != strncmp(g_current_audio_type, VCE_AUDIO_ID_FFV, sizeof(VCE_AUDIO_ID_FFV))) { vcd_state_e state = vcd_config_get_service_state(); if (VCD_STATE_READY == state) { @@ -456,6 +466,7 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb } if (g_farfieldvoice_h) { + SLOG(LOG_INFO, TAG_VCD, "[Recorder INFO] Register farfield voice audio callback"); farfield_voice_register_audio_cb(g_farfieldvoice_h, _ffv_audio_function_cb, NULL); } #endif @@ -533,6 +544,7 @@ int vcd_recorder_destroy() #ifdef TV_FFV_MODE if (NULL != g_farfieldvoice_h) { + SLOG(LOG_INFO, TAG_VCD, "[Recorder INFO] Unregister farfield voice"); farfield_voice_unregister_audio_cb(g_farfieldvoice_h); farfield_voice_final(g_farfieldvoice_h); g_farfieldvoice_h = NULL; -- 2.7.4 From 3c1fd38a789bc80615d46a52f575b2597a2249f3 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Tue, 16 Apr 2019 17:13:55 +0900 Subject: [PATCH 02/16] Check null before add match if dbus was closed or not Change-Id: I61726c900d2638ebc330a97643e3afe16276ab15 Signed-off-by: wn.jang --- client/vc_dbus.c | 41 ++++++++++++++++++++++++++++++++++++++--- client/vc_mgr_dbus.c | 46 +++++++++++++++++++++++++++++++++++++++++----- client/vc_widget_dbus.c | 21 ++++++++++++++++++++- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 5ea2841..996a188 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -18,8 +18,10 @@ #include "vc_dbus.h" #include "vc_main.h" +static pthread_mutex_t g_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_waiting_time = 3000; +static bool g_is_connection_opened = false; static Ecore_Fd_Handler* g_fd_handler = NULL; @@ -243,8 +245,11 @@ static void __vc_dbus_connection_free() int vc_dbus_open_connection() { + pthread_mutex_lock(&g_dbus_mutex); + if (NULL != g_conn_sender && NULL != g_conn_listener) { SLOG(LOG_WARN, TAG_VCC, "already existed connection "); //LCOV_EXCL_LINE + pthread_mutex_unlock(&g_dbus_mutex); return 0; } @@ -264,6 +269,7 @@ int vc_dbus_open_connection() if (NULL == g_conn_sender) { SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection "); //LCOV_EXCL_LINE + pthread_mutex_unlock(&g_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -279,6 +285,7 @@ int vc_dbus_open_connection() if (NULL == g_conn_listener) { SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection "); //LCOV_EXCL_LINE __vc_dbus_connection_free(); + pthread_mutex_unlock(&g_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -303,13 +310,15 @@ int vc_dbus_open_connection() if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { SLOG(LOG_ERROR, TAG_VCC, "fail dbus_bus_request_name()"); //LCOV_EXCL_LINE __vc_dbus_connection_free(); - return -2; + pthread_mutex_unlock(&g_dbus_mutex); + return VC_ERROR_OPERATION_FAILED; } if (NULL != g_fd_handler) { SLOG(LOG_WARN, TAG_VCC, "The handler already exists."); //LCOV_EXCL_LINE __vc_dbus_connection_free(); - return 0; + pthread_mutex_unlock(&g_dbus_mutex); + return VC_ERROR_NONE; } char rule[256] = {0, }; @@ -322,6 +331,7 @@ int vc_dbus_open_connection() SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); //LCOV_EXCL_LINE dbus_error_free(&err); __vc_dbus_connection_free(); + pthread_mutex_unlock(&g_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -329,6 +339,7 @@ int vc_dbus_open_connection() if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { SLOG(LOG_ERROR, TAG_VCC, "fail to get fd from dbus "); //LCOV_EXCL_LINE __vc_dbus_connection_free(); + pthread_mutex_unlock(&g_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_DEBUG, TAG_VCC, "Get fd from dbus : %d", fd); @@ -338,14 +349,23 @@ int vc_dbus_open_connection() if (NULL == g_fd_handler) { SLOG(LOG_ERROR, TAG_VCC, "fail to get fd handler from ecore "); //LCOV_EXCL_LINE __vc_dbus_connection_free(); + pthread_mutex_unlock(&g_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } - return 0; + g_is_connection_opened = true; + + pthread_mutex_unlock(&g_dbus_mutex); + + SLOG(LOG_INFO, TAG_VCC, "[INFO] vc client dbus connection is opened"); + + return VC_ERROR_NONE; } int vc_dbus_close_connection() { + pthread_mutex_lock(&g_dbus_mutex); + DBusError err; dbus_error_init(&err); @@ -371,6 +391,12 @@ int vc_dbus_close_connection() __vc_dbus_connection_free(); + g_is_connection_opened = false; + + pthread_mutex_unlock(&g_dbus_mutex); + + SLOG(LOG_INFO, TAG_VCC, "[INFO] vc client dbus connection is closed"); + return 0; } @@ -527,6 +553,15 @@ int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* d /* add a rule for daemon error */ char rule[256] = {0, }; snprintf(rule, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + if (NULL == g_conn_listener) { + if (g_is_connection_opened) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] g_conn_listener is NULL abnormally"); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_INFO, TAG_VCC, "[INFO] g_conn_listener is NULL and DBUS connection was closed"); + return VC_ERROR_NONE; + } + } dbus_bus_add_match(g_conn_listener, rule, &err); if (dbus_error_is_set(&err)) { diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 195d2c7..8a6eff3 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -21,7 +21,10 @@ #include "vc_command.h" +static pthread_mutex_t g_m_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; + static int g_m_waiting_time = 3000; +static bool g_is_connection_opened = false; static Ecore_Fd_Handler* g_m_fd_handler = NULL; @@ -646,9 +649,12 @@ static void __vc_mgr_dbus_connection_free() int vc_mgr_dbus_open_connection() { + pthread_mutex_lock(&g_m_dbus_mutex); + if (NULL != g_m_conn_sender && NULL != g_m_conn_listener) { SLOG(LOG_WARN, TAG_VCM, "already existed connection "); - return 0; + pthread_mutex_unlock(&g_m_dbus_mutex); + return VC_ERROR_NONE; } DBusError err; @@ -667,6 +673,7 @@ int vc_mgr_dbus_open_connection() if (NULL == g_m_conn_sender) { SLOG(LOG_ERROR, TAG_VCM, "Fail to get dbus connection "); + pthread_mutex_unlock(&g_m_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -683,6 +690,7 @@ int vc_mgr_dbus_open_connection() if (NULL == g_m_conn_listener) { SLOG(LOG_ERROR, TAG_VCM, "Fail to get dbus connection "); __vc_mgr_dbus_connection_free(); + pthread_mutex_unlock(&g_m_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -701,13 +709,15 @@ int vc_mgr_dbus_open_connection() if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { SLOG(LOG_ERROR, TAG_VCM, "fail dbus_bus_request_name()"); __vc_mgr_dbus_connection_free(); - return -2; + pthread_mutex_unlock(&g_m_dbus_mutex); + return VC_ERROR_OPERATION_FAILED; } if (NULL != g_m_fd_handler) { SLOG(LOG_WARN, TAG_VCM, "The handler already exists."); __vc_mgr_dbus_connection_free(); - return 0; + pthread_mutex_unlock(&g_m_dbus_mutex); + return VC_ERROR_NONE; } char rule[128] = {0, }; @@ -720,6 +730,7 @@ int vc_mgr_dbus_open_connection() SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); dbus_error_free(&err); __vc_mgr_dbus_connection_free(); + pthread_mutex_unlock(&g_m_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -727,6 +738,7 @@ int vc_mgr_dbus_open_connection() if (1 != dbus_connection_get_unix_fd(g_m_conn_listener, &fd)) { SLOG(LOG_ERROR, TAG_VCM, "fail to get fd from dbus "); __vc_mgr_dbus_connection_free(); + pthread_mutex_unlock(&g_m_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_DEBUG, TAG_VCM, "Get fd from dbus : %d", fd); @@ -737,14 +749,23 @@ int vc_mgr_dbus_open_connection() if (NULL == g_m_fd_handler) { SLOG(LOG_ERROR, TAG_VCM, "fail to get fd handler from ecore "); __vc_mgr_dbus_connection_free(); + pthread_mutex_unlock(&g_m_dbus_mutex); return VC_ERROR_OPERATION_FAILED; } - return 0; + g_is_connection_opened = true; + + pthread_mutex_unlock(&g_m_dbus_mutex); + + SLOG(LOG_INFO, TAG_VCM, "[INFO] manager dbus connection is opened"); + + return VC_ERROR_NONE; } int vc_mgr_dbus_close_connection() { + pthread_mutex_lock(&g_m_dbus_mutex); + DBusError err; dbus_error_init(&err); @@ -770,7 +791,13 @@ int vc_mgr_dbus_close_connection() __vc_mgr_dbus_connection_free(); - return 0; + g_is_connection_opened = false; + + pthread_mutex_unlock(&g_m_dbus_mutex); + + SLOG(LOG_INFO, TAG_VCM, "[INFO] manager dbus connection is closed"); + + return VC_ERROR_NONE; } int vc_mgr_dbus_reconnect() @@ -969,6 +996,15 @@ int vc_mgr_dbus_request_initialize(int pid, int audio_streaming_mode, int* servi /* add a rule for daemon error */ char rule_err[256] = {0, }; snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + if (NULL == g_m_conn_listener) { + if (g_is_connection_opened) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] g_m_conn_listener is NULL abnormally"); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_INFO, TAG_VCM, "[INFO] g_m_conn_listener is NULL and DBUS connection was closed"); + return VC_ERROR_NONE; + } + } dbus_bus_add_match(g_m_conn_listener, rule_err, &err); if (dbus_error_is_set(&err)) { diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index 52bee5e..adc05f5 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -25,6 +25,7 @@ static pthread_mutex_t g_w_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_w_waiting_time = 3000; +static bool g_is_connection_opened = false; static Ecore_Fd_Handler* g_w_fd_handler = NULL; @@ -279,7 +280,7 @@ int vc_widget_dbus_open_connection() if (NULL != g_w_conn_sender && NULL != g_w_conn_listener) { SLOG(LOG_WARN, TAG_VCW, "Already existed connection "); pthread_mutex_unlock(&g_w_dbus_mutex); - return 0; + return VC_ERROR_NONE; } DBusError err; @@ -383,7 +384,12 @@ int vc_widget_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } + g_is_connection_opened = true; + pthread_mutex_unlock(&g_w_dbus_mutex); + + SLOG(LOG_INFO, TAG_VCW, "[INFO] widget dbus connection is opened"); + return 0; } @@ -416,8 +422,12 @@ int vc_widget_dbus_close_connection() __vc_widget_dbus_connection_free(); + g_is_connection_opened = false; + pthread_mutex_unlock(&g_w_dbus_mutex); + SLOG(LOG_INFO, TAG_VCW, "[INFO] widget dbus connection is closed"); + return 0; } @@ -572,6 +582,15 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p /* add a rule for daemon error */ char rule_err[256] = {0, }; snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + if (NULL == g_w_conn_listener) { + if (g_is_connection_opened) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] g_w_conn_listener is NULL abnormally"); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_INFO, TAG_VCW, "[INFO] g_w_conn_listener is NULL and DBUS connection was closed"); + return VC_ERROR_NONE; + } + } dbus_bus_add_match(g_w_conn_listener, rule_err, &err); if (dbus_error_is_set(&err)) { -- 2.7.4 From f2d13483e021b5d581812acac90487d57dcb15f1 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Wed, 24 Apr 2019 20:19:20 +0900 Subject: [PATCH 03/16] Add debug code for unhandled dbus message Change-Id: I0c045bc1dddf287a69c78d211bbd5ba3e0b851fc Signed-off-by: wn.jang --- client/vc.c | 7 ------- client/vc_dbus.c | 10 +++++++++- client/vc_mgr_dbus.c | 8 +++++++- client/vc_widget_dbus.c | 8 +++++++- server/vcd_dbus.c | 8 +++++++- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/client/vc.c b/client/vc.c index cc75683..b75d098 100644 --- a/client/vc.c +++ b/client/vc.c @@ -475,11 +475,6 @@ int vc_deinitialize(void) static Eina_Bool __vc_connect_daemon(void *data) { - /* Send hello */ - if (0 != vc_dbus_request_hello()) { - return EINA_TRUE; - } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Connect daemon"); /* request initialization */ @@ -505,7 +500,6 @@ static Eina_Bool __vc_connect_daemon(void *data) vc_client_set_error(g_vc, VC_ERROR_ENGINE_NOT_FOUND); ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return EINA_FALSE; //LCOV_EXCL_STOP } else if (0 != ret) { @@ -514,7 +508,6 @@ static Eina_Bool __vc_connect_daemon(void *data) vc_client_set_error(g_vc, VC_ERROR_TIMED_OUT); ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return EINA_TRUE; } else { /* Success to connect */ diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 996a188..5b7e47d 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -216,7 +216,13 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle } /* NameOwnerChanged */ else { - SLOG(LOG_DEBUG, TAG_VCC, "Message is NOT valid"); + const char* sender = dbus_message_get_sender(msg); + const char* destination = dbus_message_get_destination(msg); + const char* path = dbus_message_get_path(msg); + const char* interf = dbus_message_get_interface(msg); + const char* member = dbus_message_get_member(msg); + int type = dbus_message_get_type(msg); + SLOG(LOG_ERROR, TAG_VCC, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); dbus_message_unref(msg); break; } @@ -448,6 +454,8 @@ int vc_dbus_request_hello() return VC_ERROR_OPERATION_FAILED; } + SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Request vc hello"); //LCOV_EXCL_LINE + DBusMessage* msg; msg = dbus_message_new_method_call( diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 8a6eff3..3e334b6 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -621,7 +621,13 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* NameOwnerChanged */ else { - SLOG(LOG_INFO, TAG_VCM, "Message is NOT valid"); + const char* sender = dbus_message_get_sender(msg); + const char* destination = dbus_message_get_destination(msg); + const char* path = dbus_message_get_path(msg); + const char* interf = dbus_message_get_interface(msg); + const char* member = dbus_message_get_member(msg); + int type = dbus_message_get_type(msg); + SLOG(LOG_ERROR, TAG_VCM, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); dbus_message_unref(msg); break; } diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index adc05f5..6660c42 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -247,7 +247,13 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* NameOwnerChanged */ else { - SLOG(LOG_ERROR, TAG_VCW, "Message is NOT valid"); + const char* sender = dbus_message_get_sender(msg); + const char* destination = dbus_message_get_destination(msg); + const char* path = dbus_message_get_path(msg); + const char* interf = dbus_message_get_interface(msg); + const char* member = dbus_message_get_member(msg); + int type = dbus_message_get_type(msg); + SLOG(LOG_ERROR, TAG_VCW, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); dbus_message_unref(msg); break; } diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 4c9fde0..b77b19c 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -1229,7 +1229,13 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle vcd_dbus_server_get_tts_audio_format(g_conn_listener, msg); else { - SLOG(LOG_DEBUG, TAG_VCD, "Message is NOT valid"); + const char* sender = dbus_message_get_sender(msg); + const char* destination = dbus_message_get_destination(msg); + const char* path = dbus_message_get_path(msg); + const char* interf = dbus_message_get_interface(msg); + const char* member = dbus_message_get_member(msg); + int type = dbus_message_get_type(msg); + SLOG(LOG_ERROR, TAG_VCD, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); dbus_message_unref(msg); break; } -- 2.7.4 From 4116e4a6f2af32aee87247e79ae036fc42974d8d Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Wed, 8 May 2019 15:17:59 +0900 Subject: [PATCH 04/16] Added mutex lock for widget Change-Id: I5dc841cc223c5ff3c20b7d153316f856bd30bf52 Signed-off-by: sungrae jo --- client/vc_widget.c | 13 +++++++++++++ client/vc_widget_dbus.c | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/client/vc_widget.c b/client/vc_widget.c index c3e634c..fafdda2 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -39,6 +39,8 @@ static Ecore_Timer* g_w_start_timer = NULL; static Ecore_Timer* g_w_notify_state_timer = NULL; static Ecore_Timer* g_w_notify_result_timer = NULL; +static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER; + static Ecore_Thread* g_w_prepare_thread = NULL; static int g_w_prepare_canceled = 0; @@ -171,8 +173,10 @@ int vc_widget_initialize(vc_h* vc_w) } } + pthread_mutex_lock(&g_w_init_mutex); if (0 != vc_widget_client_create(vc_w)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to create client!!!!!"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OUT_OF_MEMORY; } @@ -182,6 +186,7 @@ int vc_widget_initialize(vc_h* vc_w) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to init config manager : %s", __vc_widget_get_error_code(__vc_widget_convert_config_error_code(ret))); vc_widget_client_destroy((*vc_w)); + pthread_mutex_unlock(&g_w_init_mutex); return __vc_widget_convert_config_error_code(ret); } @@ -190,6 +195,7 @@ int vc_widget_initialize(vc_h* vc_w) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set config changed : %d", ret); vc_config_mgr_finalize((*vc_w)->handle); vc_widget_client_destroy((*vc_w)); + pthread_mutex_unlock(&g_w_init_mutex); return __vc_widget_convert_config_error_code(ret); } @@ -199,6 +205,7 @@ int vc_widget_initialize(vc_h* vc_w) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize DB : %d", ret); vc_config_mgr_finalize((*vc_w)->handle); vc_widget_client_destroy((*vc_w)); + pthread_mutex_unlock(&g_w_init_mutex); return ret; } } @@ -207,6 +214,7 @@ int vc_widget_initialize(vc_h* vc_w) SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } @@ -253,9 +261,11 @@ int vc_widget_deinitialize(vc_h vc_w) return VC_ERROR_NONE; } + pthread_mutex_lock(&g_w_init_mutex); if (false == vc_widget_client_is_valid(vc_w)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] NOT initialized"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -307,6 +317,7 @@ int vc_widget_deinitialize(vc_h vc_w) SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } @@ -591,6 +602,8 @@ int vc_widget_unprepare(vc_h vc_w) ecore_thread_cancel(g_w_prepare_thread); } + SLOG(LOG_WARN, TAG_VCW, "[Widget] thread info %d %d %d", curr_thread_count, prev_thread_count - curr_thread_count, !ecore_thread_check(g_w_prepare_thread)); + SLOG(LOG_WARN, TAG_VCW, "[Widget] thread count %d", count); while (0 < curr_thread_count && 1 != prev_thread_count - curr_thread_count && !ecore_thread_check(g_w_prepare_thread)) { usleep(50000); diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index 6660c42..bd25de1 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -23,6 +23,7 @@ static pthread_mutex_t g_w_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_w_waiting_time = 3000; static bool g_is_connection_opened = false; @@ -527,7 +528,9 @@ int vc_widget_dbus_request_hello() int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_pid) { + pthread_mutex_lock(&g_w_init_mutex); if (0 != __dbus_check()) { + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -541,6 +544,7 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p if (NULL == msg) { SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget initialize : Fail to make message "); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget initialize : pid(%d)", pid); @@ -591,9 +595,11 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p if (NULL == g_w_conn_listener) { if (g_is_connection_opened) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] g_w_conn_listener is NULL abnormally"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_INFO, TAG_VCW, "[INFO] g_w_conn_listener is NULL and DBUS connection was closed"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } } @@ -602,6 +608,7 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message); dbus_error_free(&err); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -615,12 +622,15 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p result = VC_ERROR_TIMED_OUT; } + pthread_mutex_unlock(&g_w_init_mutex); return result; } int vc_widget_dbus_request_finalize(int pid) { + pthread_mutex_lock(&g_w_init_mutex); if (0 != __dbus_check()) { + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -636,6 +646,7 @@ int vc_widget_dbus_request_finalize(int pid) if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message); dbus_error_free(&err); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OPERATION_FAILED; } @@ -649,6 +660,7 @@ int vc_widget_dbus_request_finalize(int pid) if (NULL == msg) { SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget finalize : Fail to make message "); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget finalize : pid(%d)", pid); @@ -691,6 +703,7 @@ int vc_widget_dbus_request_finalize(int pid) result = VC_ERROR_TIMED_OUT; } + pthread_mutex_unlock(&g_w_init_mutex); return result; } -- 2.7.4 From 4590acee6cfcd5a2ff4db3237167b8ce2a93c61b Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Wed, 8 May 2019 20:55:13 +0900 Subject: [PATCH 05/16] Fix dbus issue when initialize Change-Id: I0d3d8461fd2e1a25ea35bf941ff91353a7913978 Signed-off-by: wn.jang --- client/vc_dbus.c | 15 ++++++++------- client/vc_mgr_dbus.c | 10 +++------- client/vc_widget_dbus.c | 11 +++-------- common/vc_cmd_db.c | 13 +------------ server/vcd_dbus.c | 36 ++++++++++++++++++++---------------- server/vcd_server.c | 11 ++++++++--- server/vce.c | 10 +++++----- 7 files changed, 48 insertions(+), 58 deletions(-) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 5b7e47d..c78d5db 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -21,6 +21,7 @@ static pthread_mutex_t g_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_waiting_time = 3000; +static int g_waiting_short_time = 200; static bool g_is_connection_opened = false; static Ecore_Fd_Handler* g_fd_handler = NULL; @@ -475,7 +476,7 @@ int vc_dbus_request_hello() DBusMessage* result_msg = NULL; int result = 0; - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, -1, &err); + result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_time, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE @@ -529,9 +530,12 @@ int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* d result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); dbus_message_unref(msg); + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Receive the reply for initializing"); + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE dbus_error_free(&err); + return VC_ERROR_OPERATION_FAILED; } if (NULL != result_msg) { @@ -558,6 +562,8 @@ int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* d *service_state = tmp_service_state; *daemon_pid = tmp_daemon_pid; + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Get arguments for initializing"); + /* add a rule for daemon error */ char rule[256] = {0, }; snprintf(rule, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); @@ -570,12 +576,7 @@ int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* d return VC_ERROR_NONE; } } - dbus_bus_add_match(g_conn_listener, rule, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } + dbus_bus_add_match(g_conn_listener, rule, NULL); SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : result = %d mgr = %d service = %d daemon_pid = %d", result, *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE } else { diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 3e334b6..aa20c13 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -24,6 +24,7 @@ static pthread_mutex_t g_m_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_m_waiting_time = 3000; +static int g_m_waiting_short_time = 200; static bool g_is_connection_opened = false; static Ecore_Fd_Handler* g_m_fd_handler = NULL; @@ -874,7 +875,7 @@ int vc_mgr_dbus_request_hello() DBusMessage* result_msg = NULL; int result = 0; - result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, -1, &err); + result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, g_m_waiting_short_time, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); @@ -1011,12 +1012,7 @@ int vc_mgr_dbus_request_initialize(int pid, int audio_streaming_mode, int* servi return VC_ERROR_NONE; } } - dbus_bus_add_match(g_m_conn_listener, rule_err, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); - dbus_error_free(&err); - } + dbus_bus_add_match(g_m_conn_listener, rule_err, NULL); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr initialize : result = %d, service state = %d, foreground = %d, daemon_pid = %d", result, *service_state, *foreground, *daemon_pid); diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index bd25de1..eddeb77 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -26,6 +26,7 @@ static pthread_mutex_t g_w_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_w_waiting_time = 3000; +static int g_w_waiting_short_time = 200; static bool g_is_connection_opened = false; static Ecore_Fd_Handler* g_w_fd_handler = NULL; @@ -505,7 +506,7 @@ int vc_widget_dbus_request_hello() DBusMessage* result_msg = NULL; int result = 0; - result_msg = dbus_connection_send_with_reply_and_block(g_w_conn_sender, msg, -1, &err); + result_msg = dbus_connection_send_with_reply_and_block(g_w_conn_sender, msg, g_w_waiting_short_time, &err); if (dbus_error_is_set(&err)) { if (!strncmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN, strlen(err.name))) @@ -603,14 +604,8 @@ int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_p return VC_ERROR_NONE; } } - dbus_bus_add_match(g_w_conn_listener, rule_err, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message); - dbus_error_free(&err); - pthread_mutex_unlock(&g_w_init_mutex); - return VC_ERROR_OPERATION_FAILED; - } + dbus_bus_add_match(g_w_conn_listener, rule_err, NULL); SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget initialize : result = %d service = %d daemon_pid = %d", result, *service_state, *daemon_pid); } else { diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 164dff8..0fee6eb 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -391,9 +391,6 @@ static int __vc_db_get_commands(sqlite3* db_handle, int pid, vc_cmd_type_e type, if (VC_COMMAND_TYPE_BACKGROUND == type && 0 == strncmp(appid, temp_text, strlen(appid))) { SLOG(LOG_DEBUG, vc_db_tag(), "Skip get background commands when app is foreground, appid(%s)", appid); - free(temp_text); - temp_text = NULL; - vc_cmd_destroy(temp_cmd); temp_cmd = NULL; @@ -405,11 +402,6 @@ static int __vc_db_get_commands(sqlite3* db_handle, int pid, vc_cmd_type_e type, } } - if (NULL != temp_text) { - free(temp_text); - temp_text = NULL; - } - temp = sqlite3_column_int(stmt, 0); vc_cmd_set_id(temp_cmd, temp); @@ -870,10 +862,6 @@ static int __vc_db_get_result(sqlite3* db_handle, char** result_text, int* event __vc_db_extract_unfixed_command(*result_text, temp_fixed, &temp_unfixed); vc_cmd_set_command(temp_cmd, temp_fixed); vc_cmd_set_unfixed_command(temp_cmd, temp_unfixed); - if (NULL != temp_unfixed) { - free(temp_unfixed); - temp_unfixed = NULL; - } } else { vc_cmd_set_command(temp_cmd, temp_command); } @@ -1773,6 +1761,7 @@ static int __vc_db_insert_command(sqlite3* db_handle, int pid, vc_cmd_type_e typ g_slist_free(cmd_list); SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to insert command, %d", ret); + vc_cmd_destroy((vc_cmd_h)tmp_cmd); return ret; } cmd_list = NULL; diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index b77b19c..462f1a6 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -1079,6 +1079,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle /* loop again if we haven't read a message */ if (NULL == msg) { + SLOG(LOG_INFO, TAG_VCD, "@@@ no Dbus message anymore"); break; } @@ -1317,24 +1318,12 @@ int vcd_dbus_open_connection() } /* Flush messages which are received before fd event handler registration */ - while (DBUS_DISPATCH_DATA_REMAINS == dbus_connection_get_dispatch_status(g_conn_listener)) { + while (DBUS_DISPATCH_COMPLETE != dbus_connection_get_dispatch_status(g_conn_listener)) { + SLOG(LOG_DEBUG, TAG_VCD, "Dbus data is remained, g_conn_listener(%p)", g_conn_listener); listener_event_callback(NULL, NULL); } - /* add a rule for getting signal */ - char rule[128]; - snprintf(rule, 128, "type='signal',interface='%s'", VC_SERVER_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_conn_listener, rule, &err);/* see signals from the given interface */ - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_add_match() : %s", err.message); - dbus_error_free(&err); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - + /* add fd handler to receive dbus metohd */ int fd = 0; if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { SLOG(LOG_ERROR, TAG_VCD, "fail to get fd from dbus "); @@ -1344,7 +1333,6 @@ int vcd_dbus_open_connection() SLOG(LOG_DEBUG, TAG_VCD, "Get fd from dbus : %d", fd); } - g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL); if (NULL == g_dbus_fd_handler) { @@ -1353,6 +1341,22 @@ int vcd_dbus_open_connection() return VCD_ERROR_OPERATION_FAILED; } + /* add a rule for getting signal */ + char rule[128]; + snprintf(rule, 128, "type='signal',interface='%s'", VC_SERVER_SERVICE_INTERFACE); + + /* add a rule for which messages we want to see */ + dbus_bus_add_match(g_conn_listener, rule, &err);/* see signals from the given interface */ + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_add_match() : %s", err.message); + dbus_error_free(&err); + __vcd_dbus_connection_free(); + return VCD_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to open dbus connection"); + return 0; } diff --git a/server/vcd_server.c b/server/vcd_server.c index fe5f960..41deae9 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -548,10 +548,9 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c filtered_count = 1; top_priority = temp_cmd->priority; } - - vc_cmd_destroy((vc_cmd_h)temp_cmd); - temp_cmd = NULL; } + vc_cmd_destroy((vc_cmd_h)temp_cmd); + temp_cmd = NULL; } // ASR consume @@ -1251,6 +1250,12 @@ int vcd_initialize(vce_request_callback_s *callback) /* Initialize manager info */ vcd_client_manager_unset(); + /* Open dbus connection */ + if (0 != vcd_dbus_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); + return VCD_ERROR_OPERATION_FAILED; + } + vcd_config_set_service_state(VCD_STATE_READY); // vcdc_send_service_state(VCD_STATE_READY); diff --git a/server/vce.c b/server/vce.c index cc9f73f..3b89000 100644 --- a/server/vce.c +++ b/server/vce.c @@ -151,11 +151,11 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) return VCE_ERROR_OPERATION_FAILED; } - if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); - ecore_shutdown(); - return VCE_ERROR_OPERATION_FAILED; - } + // if (0 != vcd_dbus_open_connection()) { + // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); + // ecore_shutdown(); + // return VCE_ERROR_OPERATION_FAILED; + // } ret = vcd_initialize(callback); if (0 != ret) { -- 2.7.4 From 7ba3d1877c2baa944c3a7fbd2ac9590c04d94cea Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Fri, 10 May 2019 14:46:13 +0900 Subject: [PATCH 06/16] Remove unnecessary 'close connection' codes Change-Id: I95cdc9b4b35912ada9c84dd44726217b4f0a9a21 Signed-off-by: wn.jang --- server/vce.c | 1 - 1 file changed, 1 deletion(-) diff --git a/server/vce.c b/server/vce.c index 3b89000..7a9bf97 100644 --- a/server/vce.c +++ b/server/vce.c @@ -160,7 +160,6 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) ret = vcd_initialize(callback); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize"); - vcd_dbus_close_connection(); ecore_shutdown(); return ret; } -- 2.7.4 From a63c952df33968231f585694fd1d6e2103de3fc4 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Wed, 15 May 2019 15:35:09 +0900 Subject: [PATCH 07/16] Fix memory deference issue Change-Id: Ied7439593b1d4c8e104f80af43b0045ba515be67 --- common/vc_cmd_db.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 0fee6eb..a395550 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -862,6 +862,9 @@ static int __vc_db_get_result(sqlite3* db_handle, char** result_text, int* event __vc_db_extract_unfixed_command(*result_text, temp_fixed, &temp_unfixed); vc_cmd_set_command(temp_cmd, temp_fixed); vc_cmd_set_unfixed_command(temp_cmd, temp_unfixed); + if (temp_unfixed) + free(temp_unfixed); + temp_unfixed = NULL; } else { vc_cmd_set_command(temp_cmd, temp_command); } @@ -1761,7 +1764,6 @@ static int __vc_db_insert_command(sqlite3* db_handle, int pid, vc_cmd_type_e typ g_slist_free(cmd_list); SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to insert command, %d", ret); - vc_cmd_destroy((vc_cmd_h)tmp_cmd); return ret; } cmd_list = NULL; -- 2.7.4 From 18fe532983f2d66d0c8842c60ee6429694abe87b Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Fri, 24 May 2019 16:07:23 +0900 Subject: [PATCH 08/16] Fix thread unsafety issue when preparing Change-Id: Idafff2ce66490ceade64919f37ad1918ad9be899 --- client/vc_widget.c | 65 ++++++++++++++++++++++++++++++++--------------------- server/vcd_server.c | 11 ++++++++- 2 files changed, 49 insertions(+), 27 deletions(-) diff --git a/client/vc_widget.c b/client/vc_widget.c index fafdda2..c185aba 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -42,7 +42,8 @@ static Ecore_Timer* g_w_notify_result_timer = NULL; static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER; static Ecore_Thread* g_w_prepare_thread = NULL; -static int g_w_prepare_canceled = 0; +static bool g_ask_to_cancel_preparing = false; +static bool g_is_prepare_thread_alive = false; static int g_daemon_pid = 0; @@ -269,7 +270,7 @@ int vc_widget_deinitialize(vc_h vc_w) return VC_ERROR_INVALID_STATE; } - g_w_prepare_canceled = 1; + g_ask_to_cancel_preparing = true; vc_state_e state; vc_widget_client_get_state(vc_w, &state); @@ -476,17 +477,22 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) SLOG(LOG_INFO, TAG_VCW, "@@@ Start prepare thread"); int ret = -1, retry_count = 0; vc_h vc_w = (vc_h)data; + g_is_prepare_thread_alive = true; /* Send hello */ while (0 != ret) { - if (g_w_prepare_canceled) { + if (g_ask_to_cancel_preparing) { SLOG(LOG_WARN, TAG_VCW, "[WARNING] Thread is canceled."); + __vc_widget_internal_unprepare(vc_w); + ecore_main_loop_thread_safe_call_async(__vc_widget_delete_focus_event_handler, NULL); + g_is_prepare_thread_alive = false; return; } if (retry_count == 30) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request hello !!"); ecore_main_loop_thread_safe_call_async(__vc_widget_delete_focus_event_handler, NULL); + g_is_prepare_thread_alive = false; return; } @@ -502,14 +508,19 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) ret = -1; retry_count = 0; while (0 != ret) { - if (g_w_prepare_canceled) { + if (g_ask_to_cancel_preparing) { SLOG(LOG_WARN, TAG_VCW, "[WARNING] Thread is canceled."); + __vc_widget_internal_unprepare(vc_w); + ecore_main_loop_thread_safe_call_async(__vc_widget_delete_focus_event_handler, NULL); + g_is_prepare_thread_alive = false; return; } if (retry_count == 10) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to connect daemon !!"); + __vc_widget_internal_unprepare(vc_w); ecore_main_loop_thread_safe_call_async(__vc_widget_delete_focus_event_handler, NULL); + g_is_prepare_thread_alive = false; return; } ret = __vc_widget_connect_daemon((void*)vc_w); @@ -520,21 +531,20 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) } SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - + g_is_prepare_thread_alive = false; return; } static void __end_prepare_thread(void *data, Ecore_Thread *thread) { - g_w_prepare_thread = NULL; SLOG(LOG_DEBUG, TAG_VCW, "@@@ End prepare thread"); + g_w_prepare_thread = NULL; } static void __cancel_prepare_thread(void *data, Ecore_Thread *thread) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Cancel prepare thread"); g_w_prepare_thread = NULL; - g_w_prepare_canceled = 1; } int vc_widget_prepare(vc_h vc_w) @@ -546,10 +556,12 @@ int vc_widget_prepare(vc_h vc_w) return VC_ERROR_NONE; } + pthread_mutex_lock(&g_w_init_mutex); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -557,6 +569,7 @@ int vc_widget_prepare(vc_h vc_w) if (state != VC_STATE_INITIALIZED) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -564,6 +577,7 @@ int vc_widget_prepare(vc_h vc_w) if (NULL == widget) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get widget handle"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -572,14 +586,15 @@ int vc_widget_prepare(vc_h vc_w) // Check ecore thread if (g_w_prepare_thread && !ecore_thread_check(g_w_prepare_thread)) { - ecore_thread_cancel(g_w_prepare_thread); - g_w_prepare_thread = NULL; + SLOG(LOG_INFO, TAG_VCW, "[INFO] prepare_thread is already runnning"); + pthread_mutex_unlock(&g_w_init_mutex); + return VC_ERROR_NONE; } - g_w_prepare_canceled = 0; + g_ask_to_cancel_preparing = false; g_w_prepare_thread = ecore_thread_run(__start_prepare_thread, __end_prepare_thread, __cancel_prepare_thread, (void*)vc_w); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } @@ -592,36 +607,33 @@ int vc_widget_unprepare(vc_h vc_w) return VC_ERROR_NONE; } - int prev_thread_count = ecore_thread_active_get(); - int curr_thread_count = prev_thread_count; + pthread_mutex_lock(&g_w_init_mutex); int count = 0; - SLOG(LOG_INFO, TAG_VCW, "[Widget] Current thread count(%d)", curr_thread_count); - + SLOG(LOG_WARN, TAG_VCW, "[Widget] prepare_thread info(%p), check(%d)", g_w_prepare_thread, ecore_thread_check(g_w_prepare_thread)); if (g_w_prepare_thread && !ecore_thread_check(g_w_prepare_thread)) { - SLOG(LOG_WARN, TAG_VCW, "[WARNING] Thread is alive. Call cancel thread."); - ecore_thread_cancel(g_w_prepare_thread); + bool ret = ecore_thread_cancel(g_w_prepare_thread); + g_ask_to_cancel_preparing = true; + SLOG(LOG_WARN, TAG_VCW, "[WARNING] Thread is alive. The cancel_thread is called, ret(%d)", ret); } - SLOG(LOG_WARN, TAG_VCW, "[Widget] thread info %d %d %d", curr_thread_count, prev_thread_count - curr_thread_count, !ecore_thread_check(g_w_prepare_thread)); - SLOG(LOG_WARN, TAG_VCW, "[Widget] thread count %d", count); - while (0 < curr_thread_count && 1 != prev_thread_count - curr_thread_count && !ecore_thread_check(g_w_prepare_thread)) { + while (g_is_prepare_thread_alive) { usleep(50000); if (100 == count) { - SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is blocked, cnt(%d), thread count(%d)", count, curr_thread_count); + SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is blocked, cnt(%d)", count); break; - } else if (0 == count % 5) { - SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is alive, cnt(%d), thread count(%d)", count, curr_thread_count); + } else if (0 != count && 0 == count % 5) { + SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is alive, cnt(%d)", count); } count++; - curr_thread_count = ecore_thread_active_get(); } - g_w_prepare_thread = NULL; + SLOG(LOG_WARN, TAG_VCW, "[Widget] prepare_thread is terminated"); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -629,6 +641,7 @@ int vc_widget_unprepare(vc_h vc_w) if (state != VC_STATE_READY) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -638,7 +651,7 @@ int vc_widget_unprepare(vc_h vc_w) g_w_notify_state_timer = ecore_timer_add(0, __vc_widget_notify_state_changed, vc_w); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - + pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } diff --git a/server/vcd_server.c b/server/vcd_server.c index 41deae9..e74003f 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1439,6 +1439,10 @@ Eina_Bool vcd_cleanup_client_all(void *data) __vcd_cleanup_client(VCD_CLIENT_TYPE_WIDGET); __vcd_cleanup_client(VCD_CLIENT_TYPE_MANAGER); + if (0 == vcd_client_get_ref_count()) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty"); + ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); + } #if 0 if (0 == vcd_client_get_list(&client_list, &client_count)) { SLOG(LOG_DEBUG, TAG_VCD, "@@@ Clean up client "); @@ -2849,6 +2853,11 @@ int vcd_server_widget_finalize(int pid) /* check if pid is valid */ if (false == vcd_client_widget_is_available(pid)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] pid is NOT valid "); + if (0 == vcd_client_get_ref_count()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty, vc-service will be terminated"); + ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); + return 0; + } return VCD_ERROR_INVALID_PARAMETER; } @@ -2858,7 +2867,7 @@ int vcd_server_widget_finalize(int pid) } if (0 == vcd_client_get_ref_count()) { - SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty"); + SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty, vc-service will be terminated"); ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); return 0; } -- 2.7.4 From e7fa2ef21ad25c68dd3e892500fc7bda819e5c7d Mon Sep 17 00:00:00 2001 From: Jongmin Lee Date: Thu, 30 May 2019 14:45:10 +0900 Subject: [PATCH 09/16] replace the use of ecore_wayland into ecore_wl2 Change-Id: I8d276f76a313426f2d85bb5447d841e8baf78f90 --- CMakeLists.txt | 6 ++++-- client/vc.c | 10 +++++----- client/vc_widget.c | 10 +++++----- packaging/voice-control.spec | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffeca96..67eb451 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,8 @@ EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") ADD_DEFINITIONS("-DVOICE_LIBDIR=\"${LIBDIR}\"") ADD_DEFINITIONS("-Werror") +# for the use of ecore_wl2 +ADD_DEFINITIONS("-DEFL_BETA_API_SUPPORT") # pkg config tool INCLUDE(FindPkgConfig) @@ -45,12 +47,12 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED - aul capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland + aul capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi farfield-voice-api ) ELSE() pkg_check_modules(pkgs REQUIRED - aul capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland + aul capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf ) ENDIF() diff --git a/client/vc.c b/client/vc.c index b75d098..77f19a7 100644 --- a/client/vc.c +++ b/client/vc.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -251,7 +251,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_DEBUG, TAG_VCC, "@@@ Focus changed"); int ret; - if (ECORE_WL_EVENT_FOCUS_IN == type) { + if (ECORE_WL2_EVENT_FOCUS_IN == type) { SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); ret = vc_dbus_set_foreground(getpid(), true); if (0 != ret) { @@ -274,7 +274,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) /* notify auth changed cb */ ecore_timer_add(0, __notify_auth_changed_cb, NULL); } - } else if (ECORE_WL_EVENT_FOCUS_OUT == type) { + } else if (ECORE_WL2_EVENT_FOCUS_OUT == type) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Set background"); ret = vc_dbus_set_foreground(getpid(), false); if (0 != ret) { @@ -534,8 +534,8 @@ static Eina_Bool __vc_connect_daemon(void *data) /* Register focus handler */ ecore_thread_main_loop_begin(); - g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); - g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + g_focus_in_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); ecore_thread_main_loop_end(); char appid[1024] = {'\0',}; diff --git a/client/vc_widget.c b/client/vc_widget.c index c185aba..0fb7460 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -16,7 +16,7 @@ #include #include -#include +#include #include "vc_cmd_db.h" #include "vc_command.h" #include "vc_config_mgr.h" @@ -327,13 +327,13 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_DEBUG, TAG_VCW, "@@@ Focus changed"); int ret; - if (ECORE_WL_EVENT_FOCUS_IN == type) { + if (ECORE_WL2_EVENT_FOCUS_IN == type) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Set foreground"); ret = vc_widget_dbus_set_foreground(getpid(), true); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground (true) : %d", ret); } - } else if (ECORE_WL_EVENT_FOCUS_OUT == type) { + } else if (ECORE_WL2_EVENT_FOCUS_OUT == type) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Set background"); ret = vc_widget_dbus_set_foreground(getpid(), false); if (0 != ret) { @@ -354,9 +354,9 @@ static void __vc_widget_add_focus_event_handler(void *data) SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] add focus event handler"); if (NULL == g_focus_in_handler) - g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_in_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, __focus_changed_cb, NULL); if (NULL == g_focus_out_handler) - g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); return; } diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 1115948..6014e70 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -23,7 +23,7 @@ BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(ecore-wayland) +BuildRequires: pkgconfig(ecore-wl2) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(json-glib-1.0) BuildRequires: pkgconfig(libgum) -- 2.7.4 From 6af8fc7934a85d4bf6bc085d77caceaf89fdd080 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 3 Jun 2019 16:24:16 +0900 Subject: [PATCH 10/16] Add line coverage comments Change-Id: I7a5310f6f1588b89ece3e4fa0727192aa1c27252 Signed-off-by: sooyeon.kim --- client/CMakeLists.txt | 3 +++ client/vc.c | 2 +- packaging/voice-control.spec | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 10ce754..29a1049 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -56,6 +56,9 @@ FOREACH(flag ${pkgs_CFLAGS}) ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +## for LCOV +#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fprofile-arcs -ftest-coverage") +#SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fprofile-arcs -ftest-coverage") ## voice control library ## ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) diff --git a/client/vc.c b/client/vc.c index b75d098..8ee5cce 100644 --- a/client/vc.c +++ b/client/vc.c @@ -2863,7 +2863,6 @@ int vc_auth_cancel(void) return ret; } -//LCOV_EXCL_STOP static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) { @@ -3322,3 +3321,4 @@ int vc_tts_unset_utterance_status_cb(void) return 0; } +//LCOV_EXCL_STOP diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 1115948..47c96b3 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -95,6 +95,11 @@ cp %{SOURCE1001} %{SOURCE1002} . %build +## for LCOV +#export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" +#export CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" +#export LDFLAGS="$LDFLAGS -lgcov" + %if "%{tizen_profile_name}" == "tv" export CFLAGS="$CFLAGS -DTV_PRODUCT" cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \ -- 2.7.4 From cc0d8793cfe1d3caf3c5fe09d6a798e5c4bd95ec Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Fri, 7 Jun 2019 17:45:49 +0900 Subject: [PATCH 11/16] Fix memory leak on tts_streaming thread Change-Id: Iebcf7035772614796f71c50de8c90ed0202e2092 --- client/vc.c | 24 ++++++++++++++++-------- client/vc_data.cpp | 4 ++-- include/voice_control_internal.h | 2 ++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/client/vc.c b/client/vc.c index 77f19a7..47fffee 100644 --- a/client/vc.c +++ b/client/vc.c @@ -2898,6 +2898,7 @@ static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) } if (200 < cnt) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Wrong request, there's no pcm data"); + vc_data_clear_tts_data(&tts_data); return; } cnt++; @@ -2905,18 +2906,25 @@ static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) SLOG(LOG_INFO, TAG_VCC, "[INFO] Finish to wait for new tts data come"); /* resume tts thread */ + vc_data_clear_tts_data(&tts_data); continue; } - SLOG(LOG_DEBUG, TAG_VCC, "tts streaming callback is called"); - vc_client_use_callback(g_vc); - callback(tts_data->event, tts_data->data, tts_data->data_size, tts_data->utt_id, user_data); - vc_client_not_use_callback(g_vc); + if (NULL != tts_data) { + SLOG(LOG_DEBUG, TAG_VCC, "tts streaming callback is called"); + vc_client_use_callback(g_vc); + callback(tts_data->event, tts_data->data, tts_data->data_size, tts_data->utt_id, user_data); + vc_client_not_use_callback(g_vc); - /* If no tts data and EVENT_FINISH */ - if (0 >= vc_data_get_tts_data_size() && VC_TTS_EVENT_FINISH == tts_data->event) { - SLOG(LOG_INFO, TAG_VCC, "[INFO] Finish tts"); - break; + /* If no tts data and EVENT_FINISH */ + if (0 >= vc_data_get_tts_data_size() && VC_TTS_EVENT_FINISH == tts_data->event) { + SLOG(LOG_INFO, TAG_VCC, "[INFO] Finish tts"); + free(tts_data); + tts_data = NULL; + break; + } + free(tts_data); + tts_data = NULL; } } } diff --git a/client/vc_data.cpp b/client/vc_data.cpp index 2358f6f..850d2e1 100644 --- a/client/vc_data.cpp +++ b/client/vc_data.cpp @@ -99,7 +99,7 @@ int vc_data_clear_tts_data(vc_tts_data_s** data) pthread_mutex_lock(&g_tts_data_mutex); - if (!g_tts_data.empty()) { + if (NULL != *data) { SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] event(%d) data(%p) size(%d)", (*data)->event, (*data)->data, (*data)->data_size); if (NULL != (*data)->data) { @@ -143,4 +143,4 @@ int vc_data_clear_tts_data_by_uttid(int utt_id) pthread_mutex_unlock(&g_tts_data_mutex); return VC_ERROR_NONE; -} \ No newline at end of file +} diff --git a/include/voice_control_internal.h b/include/voice_control_internal.h index cfbb9ea..131c7e5 100644 --- a/include/voice_control_internal.h +++ b/include/voice_control_internal.h @@ -61,6 +61,8 @@ typedef bool (*vc_asr_result_cb)(vc_result_event_e event, const char* result, vo * @brief Called when client gets TTS streaming data from vc engine service. * @since_tizen 4.0 * + * @remarks The @a buffer must be released with free() by you when you no longer need it. + * * @param[in] event The TTS event * @param[in] buffer The TTS streaming data * @param[in] len The length of the TTS streaming data -- 2.7.4 From 50daee94da73a16b05a06e35f275cac7e926c51c Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Tue, 25 Jun 2019 10:17:07 +0900 Subject: [PATCH 12/16] Connect DB after service state is ready to avoid concurrency issue Change-Id: I03caa096b651f4c61f626a6317bbd97f9aff0070 Signed-off-by: wn.jang --- client/vc.c | 20 ++++++++++++-------- client/vc_mgr.c | 19 +++++++++++-------- client/vc_widget.c | 25 ++++++++++++++----------- server/vcd_config.c | 13 +------------ server/vcd_server.c | 21 +++++++++++++++++++++ 5 files changed, 59 insertions(+), 39 deletions(-) diff --git a/client/vc.c b/client/vc.c index 47fffee..936c019 100644 --- a/client/vc.c +++ b/client/vc.c @@ -355,14 +355,6 @@ int vc_initialize(void) return __vc_convert_config_error_code(ret); } - ret = vc_db_initialize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize DB : %d", ret); //LCOV_EXCL_LINE - vc_config_mgr_finalize(g_vc->handle); //LCOV_EXCL_LINE - vc_client_destroy(g_vc); //LCOV_EXCL_LINE - return ret; - } - SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_vc->handle); SLOG(LOG_DEBUG, TAG_VCC, "@@@"); @@ -492,6 +484,13 @@ static Eina_Bool __vc_connect_daemon(void *data) if (true == vc_client_is_valid(g_vc)) { SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] g_vc is valid"); + /* Initialize DB */ + ret = vc_db_initialize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize DB : %d", ret); //LCOV_EXCL_LINE + return EINA_TRUE; + } + ret = vc_dbus_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid); //LCOV_EXCL_START if (VC_ERROR_ENGINE_NOT_FOUND == ret) { @@ -508,6 +507,11 @@ static Eina_Bool __vc_connect_daemon(void *data) vc_client_set_error(g_vc, VC_ERROR_TIMED_OUT); ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); + ret = vc_db_finalize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to finalize DB : %d", ret); //LCOV_EXCL_LINE + } + return EINA_TRUE; } else { /* Success to connect */ diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 76d7c12..6b65459 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -293,14 +293,6 @@ int vc_mgr_initialize(void) return VC_ERROR_OPERATION_FAILED; } - ret = vc_db_initialize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize DB : %d", ret); - vc_config_mgr_finalize(g_vc_m->handle + VC_MANAGER_CONFIG_HANDLE); - vc_mgr_client_destroy(g_vc_m); - return ret; - } - ret = vc_mgr_client_set_audio_streaming_mode(g_vc_m, VC_AUDIO_STREAMING_MODE_VC_SERVICE); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set audio streaming mode : %d", ret); @@ -420,6 +412,13 @@ static Eina_Bool __vc_mgr_connect_daemon(void *data) if (true == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] g_vc_m is valid"); + /* Initialize DB */ + ret = vc_db_initialize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize DB : %d", ret); + return EINA_TRUE; + } + vc_audio_streaming_mode_e streaming_mode; vc_mgr_client_get_audio_streaming_mode(g_vc_m, &streaming_mode); @@ -436,6 +435,10 @@ static Eina_Bool __vc_mgr_connect_daemon(void *data) } else if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[WARNING] Fail to connection. Retry to connect : %s", __vc_mgr_get_error_code(ret)); + ret = vc_db_finalize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to finalize DB : %d", ret); + } return EINA_TRUE; } else { /* Success to connect */ diff --git a/client/vc_widget.c b/client/vc_widget.c index 0fb7460..21bb79e 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -200,17 +200,6 @@ int vc_widget_initialize(vc_h* vc_w) return __vc_widget_convert_config_error_code(ret); } - if (1 == vc_widget_client_get_count()) { - ret = vc_db_initialize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize DB : %d", ret); - vc_config_mgr_finalize((*vc_w)->handle); - vc_widget_client_destroy((*vc_w)); - pthread_mutex_unlock(&g_w_init_mutex); - return ret; - } - } - SLOG(LOG_DEBUG, TAG_VCW, "[Success] uid(%d)", (*vc_w)->handle); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); @@ -386,6 +375,15 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) widget->conn_timer = NULL; } + /* Initialize DB */ + if (1 == vc_widget_client_get_count()) { + ret = vc_db_initialize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize DB : %d", ret); + return EINA_TRUE; + } + } + /* request initialization */ int ret = -1; int service_state = 0; @@ -408,6 +406,11 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) vc_widget_client_set_error(vc_w, VC_ERROR_TIMED_OUT); ecore_main_loop_thread_safe_call_async(__vc_widget_notify_error, vc_w); + ret = vc_db_finalize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to finalize DB : %d", ret); + } + SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return EINA_TRUE; } diff --git a/server/vcd_config.c b/server/vcd_config.c index 629487e..03114d5 100755 --- a/server/vcd_config.c +++ b/server/vcd_config.c @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "vc_cmd_db.h" #include "vc_config_mgr.h" #include "vcd_config.h" #include "vcd_main.h" @@ -72,12 +71,6 @@ int vcd_config_initialize(vcd_config_lang_changed_cb lang_cb, vcd_config_foregro return VCD_ERROR_OPERATION_FAILED; } - ret = vc_db_initialize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize DB : %d", ret); - return ret; - } - g_lang_cb = lang_cb; g_user_data = user_data; @@ -91,11 +84,7 @@ int vcd_config_finalize() vc_config_mgr_unset_lang_cb(getpid()); vc_config_mgr_finalize(getpid()); - int ret = vc_db_finalize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to finalize DB, ret(%d)", ret); - } - return ret; + return 0; } int vcd_config_get_default_language(char** language) diff --git a/server/vcd_server.c b/server/vcd_server.c index e74003f..59a2986 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1222,6 +1222,12 @@ int vcd_initialize(vce_request_callback_s *callback) SLOG(LOG_ERROR, TAG_VCD, "[Server WARNING] Fail to initialize config."); } + ret = vc_db_initialize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize DB : %d", ret); + return ret; + } + /* Remove db data */ ret = __vcd_db_clean_up(); if (0 != ret) { @@ -1318,9 +1324,24 @@ bool vcd_finalize() vcd_client_manager_unset_appid(); + ret = vcd_config_finalize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Server WARNING] Fail to finalize config."); + } + + ret = vc_db_finalize(); + if (0 != ret) { + 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); + /* Open dbus connection */ + if (0 != vcd_dbus_close_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to close connection"); + } + SLOG(LOG_ERROR, TAG_VCD, "[Server] mode finalize"); return true; -- 2.7.4 From 64317e781202128597d07ad044eede72bc3ac434 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Tue, 25 Jun 2019 10:17:07 +0900 Subject: [PATCH 13/16] connect DB after service state is ready - to avoid concurrency issue. - DB will be created on only vcd service process. Change-Id: I03caa096b651f4c61f626a6317bbd97f9aff0070 Signed-off-by: wn.jang --- client/vc_widget.c | 10 ++++++---- server/vcd_server.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client/vc_widget.c b/client/vc_widget.c index 21bb79e..a40506c 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -376,6 +376,7 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) } /* Initialize DB */ + int ret = -1; if (1 == vc_widget_client_get_count()) { ret = vc_db_initialize(); if (0 != ret) { @@ -385,7 +386,6 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) } /* request initialization */ - int ret = -1; int service_state = 0; ret = vc_widget_dbus_request_initialize(getpid(), &service_state, &g_daemon_pid); @@ -406,9 +406,11 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) vc_widget_client_set_error(vc_w, VC_ERROR_TIMED_OUT); ecore_main_loop_thread_safe_call_async(__vc_widget_notify_error, vc_w); - ret = vc_db_finalize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to finalize DB : %d", ret); + if (1 == vc_widget_client_get_count()) { + ret = vc_db_finalize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to finalize DB : %d", ret); + } } SLOG(LOG_DEBUG, TAG_VCW, "@@@"); diff --git a/server/vcd_server.c b/server/vcd_server.c index 59a2986..c640d82 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1324,7 +1324,7 @@ bool vcd_finalize() vcd_client_manager_unset_appid(); - ret = vcd_config_finalize(); + int ret = vcd_config_finalize(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server WARNING] Fail to finalize config."); } -- 2.7.4 From 9d5297a25a2e8eb618256973e1379e1376776b3c Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Wed, 26 Jun 2019 14:59:17 +0900 Subject: [PATCH 14/16] Update to connect DB logic Change-Id: I52d16f5c2a9f4b560aeaed1d60a72fdcac423f8d --- client/vc.c | 8 ++--- common/vc_cmd_db.c | 103 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 72 insertions(+), 39 deletions(-) diff --git a/client/vc.c b/client/vc.c index 936c019..d025015 100644 --- a/client/vc.c +++ b/client/vc.c @@ -476,10 +476,6 @@ static Eina_Bool __vc_connect_daemon(void *data) g_connect_timer = NULL; - ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); - if (0 != ret) - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE - /* check handle */ if (true == vc_client_is_valid(g_vc)) { SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] g_vc is valid"); @@ -491,6 +487,10 @@ static Eina_Bool __vc_connect_daemon(void *data) return EINA_TRUE; } + ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); + if (0 != ret) + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE + ret = vc_dbus_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid); //LCOV_EXCL_START if (VC_ERROR_ENGINE_NOT_FOUND == ret) { diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index a395550..be4b790 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -62,6 +62,8 @@ char* g_path = NULL; char* g_backup_path = NULL; int g_fpid = -1; int g_ref_cnt = 0; +int g_db_cnt = 0; +int g_backup_db_cnt = 0; static int __vc_db_transaction(sqlite3* db_handle, const char* transaction) { @@ -1319,6 +1321,30 @@ static int __vc_db_integrity_check_cb(void *NotUsed, int argc, char **argv, char return 0; } +bool __vc_db_connect_db(char** path, sqlite3** db_handle) +{ + bool is_connect = false; + int ret = __vc_db_open_db(path, db_handle); + if (0 != ret) { + int cnt = 0; + while (cnt <= 5) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB"); + + usleep(100000); + if (0 == __vc_db_open_db(path, db_handle)) { + SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to open DB"); + is_connect = true; + break; + } + cnt++; + } + } else { + SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to open DB"); + is_connect = true; + } + return is_connect; +} + int vc_db_initialize(void) { SLOG(LOG_INFO, vc_db_tag(), "DB initialization"); @@ -1345,60 +1371,67 @@ int vc_db_initialize(void) } snprintf(g_backup_path, 256, "%s/.vc_backup.db", VC_RUNTIME_INFO_ROOT); - if (0 != __vc_db_open_db(&g_path, &g_db_handle)) { - int cnt = 0; - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB"); + bool is_connect = __vc_db_connect_db(&g_path, &g_db_handle); + if (false == is_connect) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to connect main DB, retry to connect after removing file"); if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_path); + g_db_cnt = (g_db_cnt++) % 1000; + snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } - if (0 != __vc_db_open_db(&g_path, &g_db_handle)) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB"); - } - while (cnt <= 5) { - if (0 != __vc_db_open_db(&g_backup_path, &g_db_backup_handle)) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open backup DB"); - } else { - break; + is_connect = __vc_db_connect_db(&g_path, &g_db_handle); + if (true == is_connect) { + SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect main DB"); + is_connect = __vc_db_connect_db(&g_backup_path, &g_db_backup_handle); + if (true == is_connect) { + SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect backup DB"); + if (0 != vc_db_restore_command()) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to restore command"); + } } - cnt++; - } - if (0 != vc_db_restore_command()) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to restore command"); + } else { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to connect main DB"); + return VC_DB_ERROR_OPERATION_FAILED; } } if (SQLITE_CORRUPT == sqlite3_exec(g_db_handle, "pragma integrity_check", __vc_db_integrity_check_cb, NULL, NULL)) { - int cnt = 0; SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB"); if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_path); + g_db_cnt = (g_db_cnt++) % 1000; + snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } - if (0 != __vc_db_open_db(&g_path, &g_db_handle)) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB"); - } - while (cnt <= 5) { - if (0 != __vc_db_open_db(&g_backup_path, &g_db_backup_handle)) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open backup DB"); - } else { - break; + is_connect = __vc_db_connect_db(&g_path, &g_db_handle); + if (true == is_connect) { + SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect main DB"); + is_connect = __vc_db_connect_db(&g_backup_path, &g_db_backup_handle); + if (true == is_connect) { + SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect backup DB"); + if (0 != vc_db_restore_command()) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to restore command"); + } } - cnt++; - } - if (0 != vc_db_restore_command()) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to restore command"); + } else { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to connect main DB"); + return VC_DB_ERROR_OPERATION_FAILED; } } - if (0 != __vc_db_open_db(&g_backup_path, &g_db_backup_handle)) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open backup DB"); + is_connect = __vc_db_connect_db(&g_backup_path, &g_db_backup_handle); + if (false == is_connect) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open backup DB, retry to connect after removing file"); if (0 != remove(g_backup_path)) { + g_backup_db_cnt = (g_backup_db_cnt++) % 1000; SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_backup_path); + snprintf(g_backup_path, 256, "%s/.vc_backup_%d.db", VC_RUNTIME_INFO_ROOT, g_backup_db_cnt); } - if (0 != __vc_db_open_db(&g_backup_path, &g_db_backup_handle)) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open backup DB"); - } - if (0 != vc_db_backup_command()) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to backup command"); + is_connect = __vc_db_connect_db(&g_path, &g_db_backup_handle); + if (true == is_connect) { + SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect backup DB"); + if (0 != vc_db_restore_command()) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to restore command"); + } } } -- 2.7.4 From 474b2d2b9ca134e545ad0bbb2d0985f139e865ec Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Wed, 26 Jun 2019 16:51:40 +0900 Subject: [PATCH 15/16] Fix build error Change-Id: Ida040f10099fe2cfb5d1f4aac3f1998ca37f231a --- common/vc_cmd_db.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index be4b790..ade3f93 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1376,7 +1376,7 @@ int vc_db_initialize(void) SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to connect main DB, retry to connect after removing file"); if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_path); - g_db_cnt = (g_db_cnt++) % 1000; + g_db_cnt = (g_db_cnt + 1) % 1000; snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } is_connect = __vc_db_connect_db(&g_path, &g_db_handle); @@ -1399,7 +1399,7 @@ int vc_db_initialize(void) SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB"); if (0 != remove(g_path)) { SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_path); - g_db_cnt = (g_db_cnt++) % 1000; + g_db_cnt = (g_db_cnt + 1) % 1000; snprintf(g_path, 256, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); } is_connect = __vc_db_connect_db(&g_path, &g_db_handle); @@ -1422,7 +1422,7 @@ int vc_db_initialize(void) if (false == is_connect) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open backup DB, retry to connect after removing file"); if (0 != remove(g_backup_path)) { - g_backup_db_cnt = (g_backup_db_cnt++) % 1000; + g_backup_db_cnt = (g_backup_db_cnt + 1) % 1000; SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed", g_backup_path); snprintf(g_backup_path, 256, "%s/.vc_backup_%d.db", VC_RUNTIME_INFO_ROOT, g_backup_db_cnt); } -- 2.7.4 From 9348a7e2867a3b8f8dc24d3cc665cbe86680b87a Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 5 Jul 2019 13:23:54 +0900 Subject: [PATCH 16/16] Add gcov package generation feature Change-Id: I1763d43a6607da2541cd50bd8023452482a5b6cf Signed-off-by: sooyeon.kim --- packaging/voice-control.spec | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index a6e7757..d7c2919 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -89,16 +89,27 @@ Requires: %{name} = %{version}-%{release} %description engine-devel Voice control engine header files for VC development. +%if 0%{?gcov:1} +%package gcov +Summary: Voice control (gcov) +Group: Graphics & UI Framework/Voice Framework +%description gcov +Voice control gcov objects +%endif + + %prep %setup -q -n %{name}-%{version} cp %{SOURCE1001} %{SOURCE1002} . %build -## for LCOV -#export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" -#export CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" -#export LDFLAGS="$LDFLAGS -lgcov" +%if 0%{?gcov:1} +export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" +export CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" +export FFLAGS="$FFLAGS -fprofile-arcs -ftest-coverage" +export LDFLAGS="$LDFLAGS -lgcov" +%endif %if "%{tizen_profile_name}" == "tv" export CFLAGS="$CFLAGS -DTV_PRODUCT" @@ -110,6 +121,11 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DIN %endif make %{?jobs:-j%jobs} +%if 0%{?gcov:1} +mkdir -p gcov-obj +find . -name '*.gcno' -exec cp '{}' gcov-obj ';' +%endif + %install rm -rf %{buildroot} @@ -119,6 +135,11 @@ mv -f org.tizen.voice.vcserver.tv.service org.tizen.voice.vcserver.service %make_install +%if 0%{?gcov:1} +mkdir -p %{buildroot}%{_datadir}/gcov/obj +install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj +%endif + %post /sbin/ldconfig @@ -185,3 +206,7 @@ mkdir -p %{_libdir}/voice/vc %{_includedir}/vce.h %{_includedir}/vce_internal.h +%if 0%{?gcov:1} +%files gcov +%{_datadir}/gcov/obj/* +%endif -- 2.7.4