From bfd134c48f23c41430cc6163e7b62ef6dc6a4410 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 3 Feb 2017 14:36:37 +0900 Subject: [PATCH 01/16] Add null checker before strcmp Change-Id: Ia596f10ff6ec3403d2516f811eef628ddf2c8977 Signed-off-by: sooyeon.kim (cherry picked from commit 00f4da760eda5e4e0c1d328f2f9c3d01e3addc58) --- common/vc_info_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index da0ab55..08db797 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -320,7 +320,7 @@ int vc_info_parser_get_result(char** result_text, int* event, char** result_mess SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Insert db is failed, ret = %d", ret); } - if (!strcmp(temp_text, "#NULL")) { + if (NULL == temp_text || !strcmp(temp_text, "#NULL")) { *result_text = NULL; } else { *result_text = strdup(temp_text); -- 2.7.4 From 2d78429c2a2adf7f1152a0c01d98fc8f5fc3e58e Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 14 Feb 2017 15:29:35 +0900 Subject: [PATCH 02/16] Fix memory leak / Add null check Change-Id: I4722250cf76b9c547126f86ad33735908d7ecfcd Signed-off-by: Suyeon Hwang (cherry picked from commit 40b947aeaf1f42c86595ba60980785b4dc4b85d0) --- client/vc_widget.c | 13 +++++++++++-- common/vc_cmd_db.c | 35 ++++++++++++++++++++++++++++------- common/vc_command.c | 7 +++++++ common/vc_config_parser.c | 1 + 4 files changed, 47 insertions(+), 9 deletions(-) mode change 100755 => 100644 common/vc_command.c diff --git a/client/vc_widget.c b/client/vc_widget.c index 98843fc..c671570 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -213,7 +213,7 @@ int vc_widget_deinitialize(vc_h vc_w) } /* no break. need to next step*/ case VC_STATE_INITIALIZED: - if (NULL != widget->conn_timer) { + if (NULL != widget && NULL != widget->conn_timer) { SLOG(LOG_DEBUG, TAG_VCW, "Connect Timer is deleted"); ecore_timer_del(widget->conn_timer); widget->conn_timer = NULL; @@ -288,7 +288,9 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Connect daemon"); vc_widget_s* widget = widget_get(vc_w); - widget->conn_timer = NULL; + if (NULL != widget) { + widget->conn_timer = NULL; + } /* request initialization */ int ret = -1; @@ -367,6 +369,13 @@ int vc_widget_prepare(vc_h vc_w) } vc_widget_s* widget = widget_get(vc_w); + if (NULL == widget) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get widget handle"); + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, " "); + return VC_ERROR_INVALID_STATE; + } + widget->conn_timer = ecore_timer_add(0, __vc_widget_connect_daemon, (void*)vc_w); SLOG(LOG_DEBUG, TAG_VCW, "====="); diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 3a040a6..01ae1e9 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1393,6 +1393,10 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) int ret = __vc_db_generate_command(tmp_cmd, &fixed_cmd, &cmd_list); if (0 != ret) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to generate command, %d", ret); + + if (NULL != tmp_cmd) { + vc_cmd_destroy((vc_cmd_h)tmp_cmd); + } return ret; } @@ -1415,14 +1419,14 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) else tmp_cmd->fixed = NULL; - int ret = __vc_db_insert_commands(pid, type, tmp_cmd); + ret = __vc_db_insert_commands(pid, type, tmp_cmd); if (ret != VC_DB_ERROR_NONE) { if (NULL != fixed_cmd) { free(fixed_cmd); fixed_cmd = NULL; } vc_cmd_destroy((vc_cmd_h)tmp_cmd); - return ret; + break; } if (VC_COMMAND_TYPE_BACKGROUND == type && NULL != tmp_cmd->invocation_name) { @@ -1440,16 +1444,33 @@ int vc_db_insert_command(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) fixed_cmd = NULL; } vc_cmd_destroy((vc_cmd_h)tmp_cmd); - return ret; + break; } } - - } - if (NULL != temp_command) { + cmd_list = g_slist_remove(cmd_list, temp_command); free(temp_command); temp_command = NULL; } - iter = g_slist_next(iter); + iter = g_slist_nth(cmd_list, 0); + } + + if (VC_DB_ERROR_NONE != ret) { + while (NULL != iter) { + temp_command = iter->data; + + if (NULL != temp_command) { + cmd_list = g_slist_remove(cmd_list, temp_command); + free(temp_command); + temp_command = NULL; + } + + iter = g_slist_nth(cmd_list, 0); + } + + g_slist_free(cmd_list); + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to insert command, %d", ret); + + return ret; } cmd_list = NULL; } diff --git a/common/vc_command.c b/common/vc_command.c old mode 100755 new mode 100644 index b085344..3f3f719 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -361,6 +361,9 @@ int vc_cmd_list_remove_all(vc_cmd_list_h vc_cmd_list, bool release_command) SLOG(LOG_DEBUG, TAG_VCCMD, "Free command(%p)", temp_cmd); if (NULL != temp_cmd->command) free(temp_cmd->command); if (NULL != temp_cmd->parameter) free(temp_cmd->parameter); + if (NULL != temp_cmd->appid) free(temp_cmd->appid); + if (NULL != temp_cmd->invocation_name) free(temp_cmd->invocation_name); + if (NULL != temp_cmd->fixed) free(temp_cmd->fixed); free(temp_cmd); temp_cmd = NULL; } @@ -698,6 +701,10 @@ int vc_cmd_create(vc_cmd_h* vc_command) command->priority = 0; command->key = VC_KEY_NONE; command->modifier = VC_MODIFIER_NONE; + command->invocation_name = NULL; + command->parameter = NULL; + command->appid = NULL; + command->fixed = NULL; *vc_command = (vc_cmd_h)command; diff --git a/common/vc_config_parser.c b/common/vc_config_parser.c index 92ca095..050d697 100644 --- a/common/vc_config_parser.c +++ b/common/vc_config_parser.c @@ -386,6 +386,7 @@ int vc_parser_load_config(vc_config_s** config_info) SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Enabled service is wrong"); temp->enabled = false; } + xmlFree(key); } else { SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Enabled service is NULL"); } -- 2.7.4 From 35d0f43aa26a1d6eb91d76dd9c627d8b7b72572b Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 21 Feb 2017 14:43:23 +0900 Subject: [PATCH 03/16] Fix memory leak Change-Id: I6ec3ee020a742aeffae127383134f575ecf704f0 Signed-off-by: Suyeon Hwang (cherry picked from commit 3fcede4baff208089bc91dae037bc8f048a7854a) --- common/vc_cmd_db.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++ common/vc_info_parser.c | 11 ++++ 2 files changed, 150 insertions(+) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 01ae1e9..3cf4094 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -133,11 +133,16 @@ static int __vc_db_delete_commands(int pid, vc_cmd_type_e type, const char* appi ret = sqlite3_prepare_v2(db_handle, sql, -1, &stmt, NULL); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] sqlite3_prepare_v2: %s", sqlite3_errmsg(db_handle)); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 1, (int)type); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } @@ -147,6 +152,10 @@ static int __vc_db_delete_commands(int pid, vc_cmd_type_e type, const char* appi ret = sqlite3_bind_text(stmt, 2, appid, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } SLOG(LOG_DEBUG, vc_db_tag(), "[SQL] DELETE FROM vc_info WHERE type = %d AND appid = %s", type, appid); @@ -154,6 +163,10 @@ static int __vc_db_delete_commands(int pid, vc_cmd_type_e type, const char* appi ret = sqlite3_bind_int(stmt, 2, pid); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } SLOG(LOG_DEBUG, vc_db_tag(), "[SQL] DELETE FROM vc_info WHERE type = %d AND pid = %d", type, pid); @@ -162,6 +175,10 @@ static int __vc_db_delete_commands(int pid, vc_cmd_type_e type, const char* appi ret = sqlite3_step(stmt); if (ret != SQLITE_DONE) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_step: fail returned, sql(%s), ret(%d), err(%s)", sql, ret, sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } @@ -189,26 +206,35 @@ static int __vc_db_insert_commands(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) ret = sqlite3_bind_int(stmt, 2, pid); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 3, cmd->type); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 4, cmd->format); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 5, cmd->domain); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 6, cmd->command, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } @@ -227,23 +253,31 @@ static int __vc_db_insert_commands(int pid, vc_cmd_type_e type, vc_cmd_s* cmd) ret = sqlite3_bind_text(stmt, 8, cmd->appid, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } if (VC_COMMAND_TYPE_BACKGROUND == type && NULL != cmd->invocation_name) { ret = sqlite3_bind_text(stmt, 9, cmd->invocation_name, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } } ret = sqlite3_bind_text(stmt, 10, cmd->fixed, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: err(%s)", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_step(stmt); if (ret != SQLITE_DONE) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_step: fail returned %d, %s", ret, sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } @@ -287,12 +321,19 @@ static int __vc_db_get_commands(int pid, vc_cmd_type_e type, GSList** cmd_list) ret = sqlite3_bind_int(stmt, 1, (int)type); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } if (VC_COMMAND_TYPE_BACKGROUND != type) { ret = sqlite3_bind_int(stmt, 2, pid); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } } @@ -305,6 +346,10 @@ static int __vc_db_get_commands(int pid, vc_cmd_type_e type, GSList** cmd_list) ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { SLOG(LOG_DEBUG, vc_db_tag(), "No matched commands"); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_NONE; } @@ -325,6 +370,11 @@ static int __vc_db_get_commands(int pid, vc_cmd_type_e type, GSList** cmd_list) free(appid); appid = NULL; } + sqlite3_reset(stmt); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OUT_OF_MEMORY; } @@ -447,21 +497,28 @@ static int __vc_db_insert_result(const char* result_text, int event, const char* ret = sqlite3_bind_text(stmt, 2, result_text, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 3, event); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 4, msg, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 5, exclusive); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } @@ -471,6 +528,8 @@ static int __vc_db_insert_result(const char* result_text, int event, const char* ret = sqlite3_step(stmt); if (ret != SQLITE_DONE) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_step: fail returned %d, %s", ret, sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } sqlite3_reset(stmt); @@ -493,51 +552,71 @@ static int __vc_db_insert_result(const char* result_text, int event, const char* ret = sqlite3_bind_int(stmt, 6, cmd->pid); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 7, cmd->type); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 8, cmd->format); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 9, cmd->domain); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 10, cmd->command, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 11, cmd->parameter, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 12, cmd->appid, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 13, cmd->invocation_name, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 14, cmd->fixed, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_text: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_step(stmt); if (ret != SQLITE_DONE) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_step: fail returned %d, %s", ret, sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } @@ -630,24 +709,36 @@ static int __vc_db_get_result(char** result_text, int* event, char** msg, int pi ret = sqlite3_prepare_v2(db_handle, sql, -1, &stmt, NULL); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] sqlite3_prepare_v2: %s", sqlite3_errmsg(db_handle)); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } if (NULL != appid) { ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } } else if (-1 != pid) { ret = sqlite3_bind_int(stmt, 1, pid); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } } ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { SLOG(LOG_DEBUG, vc_db_tag(), "No matched commands"); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_NONE; } @@ -689,6 +780,12 @@ static int __vc_db_get_result(char** result_text, int* event, char** msg, int pi free(*msg); *msg = NULL; } + + sqlite3_reset(stmt); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return -1; } @@ -778,6 +875,11 @@ static int __vc_db_get_result(char** result_text, int* event, char** msg, int pi *msg = NULL; } + sqlite3_reset(stmt); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); + free(sql); + sql = NULL; return VC_DB_ERROR_OPERATION_FAILED; } @@ -811,17 +913,22 @@ static int __vc_db_get_appid(const char* result, GSList** app_list) ret = sqlite3_bind_int(stmt, 1, VC_COMMAND_TYPE_BACKGROUND); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_text(stmt, 2, result, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } SLOG(LOG_DEBUG, vc_db_tag(), "[SQL] SELECT * FROM vc_result WHERE type = 2 and result = %s", result); ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { SLOG(LOG_DEBUG, vc_db_tag(), "No matched commands"); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_NONE; } @@ -831,6 +938,15 @@ static int __vc_db_get_appid(const char* result, GSList** app_list) temp_app = (vc_deactivated_app_s*)calloc(1, sizeof(vc_deactivated_app_s)); if (NULL == temp_app) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] memory allcation fail"); + + if (NULL != temp_app_list) { + g_slist_free_full(temp_app_list, free); + temp_app_list = NULL; + } + + sqlite3_reset(stmt); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OUT_OF_MEMORY; } @@ -869,11 +985,14 @@ int __vc_db_get_result_pid_list(const char* result, GSList** pid_list) ret = sqlite3_bind_text(stmt, 1, result, -1, SQLITE_TRANSIENT); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { SLOG(LOG_DEBUG, vc_db_tag(), "No matched commands"); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_NONE; } @@ -885,6 +1004,15 @@ int __vc_db_get_result_pid_list(const char* result, GSList** pid_list) temp_cmd = (vc_cmd_s*)calloc(1, sizeof(vc_cmd_s)); if (NULL == temp_cmd) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] memory allcation fail"); + + if (NULL != temp_pid_list) { + g_slist_free_full(temp_pid_list, free); + temp_pid_list = NULL; + } + + sqlite3_reset(stmt); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OUT_OF_MEMORY; } @@ -928,16 +1056,21 @@ static int __vc_db_append_commands(int pid, int type, vc_cmd_list_h vc_cmd_list) ret = sqlite3_bind_int(stmt, 1, pid); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_bind_int(stmt, 2, type); if (ret != SQLITE_OK) { SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_bind_int: %s", sqlite3_errmsg(db_handle)); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } ret = sqlite3_step(stmt); if (ret == SQLITE_DONE) { SLOG(LOG_DEBUG, vc_db_tag(), "No matched commands"); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_NONE; } @@ -951,6 +1084,9 @@ static int __vc_db_append_commands(int pid, int type, vc_cmd_list_h vc_cmd_list) if (0 != vc_cmd_create(&temp_cmd)) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create command!!"); + sqlite3_reset(stmt); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return -1; } temp = sqlite3_column_int(stmt, 0); @@ -992,6 +1128,9 @@ static int __vc_db_append_commands(int pid, int type, vc_cmd_list_h vc_cmd_list) SLOG(LOG_DEBUG, vc_db_tag(), "Fail to add command to list"); vc_cmd_destroy(temp_cmd); vc_cmd_list_destroy(vc_cmd_list, true); + sqlite3_reset(stmt); + sqlite3_clear_bindings(stmt); + sqlite3_finalize(stmt); return VC_DB_ERROR_OPERATION_FAILED; } diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 08db797..770ca29 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -191,6 +191,12 @@ int vc_info_parser_get_demandable_clients(GSList** client_list) if (NULL == temp_client) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Memory alloc error!!"); + + if (NULL != temp_client_list) { + g_slist_free_full(temp_client_list, free); + temp_client_list = NULL; + } + xmlFree(key); xmlFreeDoc(doc); return -1; } @@ -589,6 +595,11 @@ int vc_info_parser_get_client_info(GSList** client_info_list) if (NULL == client) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Memory alloc error!!"); + + if (NULL != temp_client_list) { + g_slist_free_full(temp_client_list, free); + temp_client_list = NULL; + } xmlFreeDoc(doc); return -1; } -- 2.7.4 From 2a9554d0f6ba6bb12debc1ee4fcb4eb0fa8936f1 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 27 Feb 2017 15:41:42 +0900 Subject: [PATCH 04/16] Fix memory leak / Add type casting Change-Id: I4662a6c54b34717ef0749b8beea9a4d3e2e8d09a Signed-off-by: Suyeon Hwang (cherry picked from commit ba53ae91923a97f37f3c0020d9e192415fff8430) --- common/vc_cmd_db.c | 25 ++++++++++++++++++++++++- common/vc_command.c | 37 +++++++++++++++++++++++++++++++------ common/vc_config_parser.c | 2 ++ common/vc_info_parser.c | 16 +++++++++++++++- include/voice_control.h | 2 +- server/vcd_engine_agent.c | 23 +++++++++++++++++++---- 6 files changed, 92 insertions(+), 13 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 3cf4094..4218894 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -897,6 +897,20 @@ static int __vc_db_get_result(char** result_text, int* event, char** msg, int pi return VC_DB_ERROR_NONE; } +void __vc_db_demandable_client_free(void* data) +{ + vc_deactivated_app_s* d_app = (vc_deactivated_app_s*)data; + + if (NULL != d_app) { + if (NULL != d_app->appid) { + free(d_app->appid); + d_app->appid = NULL; + } + + free(d_app); + } +} + static int __vc_db_get_appid(const char* result, GSList** app_list) { GSList* temp_app_list = NULL; @@ -940,7 +954,7 @@ static int __vc_db_get_appid(const char* result, GSList** app_list) SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] memory allcation fail"); if (NULL != temp_app_list) { - g_slist_free_full(temp_app_list, free); + g_slist_free_full(temp_app_list, __vc_db_demandable_client_free); temp_app_list = NULL; } @@ -1225,6 +1239,9 @@ int vc_db_initialize(void) db_util_close(db_handle); db_handle = NULL; } + + free(path); + path = NULL; return VC_DB_ERROR_OPERATION_FAILED; } @@ -1234,6 +1251,9 @@ int vc_db_initialize(void) if (db_handle) db_util_close(db_handle); db_handle = NULL; + + free(path); + path = NULL; return VC_DB_ERROR_OPERATION_FAILED; } @@ -1242,6 +1262,9 @@ int vc_db_initialize(void) if (db_handle) db_util_close(db_handle); db_handle = NULL; + + free(path); + path = NULL; return VC_DB_ERROR_OPERATION_FAILED; } diff --git a/common/vc_command.c b/common/vc_command.c index 3f3f719..bd0511d 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -1738,7 +1738,12 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) ret = regexec(®[4], str, 2, pmatch, 0); if (0 == ret) { len = pmatch[1].rm_eo - pmatch[1].rm_so; - tempstr = strndup(str + pmatch[1].rm_so, len); + + if (0 > len) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); + return VC_ERROR_OPERATION_FAILED; + } + tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -1759,7 +1764,12 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) ret = regexec(®[5], str, 2, pmatch, 0); if (0 == ret) { len = pmatch[1].rm_eo - pmatch[1].rm_so; - tempstr = strndup(str + pmatch[1].rm_so, len); + + if (0 > len) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); + return VC_ERROR_OPERATION_FAILED; + } + tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -1828,7 +1838,12 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) ret = regexec(®[1], str, 2, pmatch, 0); if (0 == ret) { len = pmatch[1].rm_eo - pmatch[1].rm_so; - tempstr = strndup(str + pmatch[1].rm_so, len); + + if (0 > len) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); + return VC_ERROR_OPERATION_FAILED; + } + tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -1866,7 +1881,7 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) idx = 1; len = pmatch[idx].rm_eo - pmatch[idx].rm_so; if (0 < len) { - tempstr = strndup(str + pmatch[idx].rm_so, len); + tempstr = strndup(str + pmatch[idx].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -2015,7 +2030,12 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) ret = regexec(®[9], str, 2, pmatch, 0); if (0 == ret) { len = pmatch[1].rm_eo - pmatch[1].rm_so; - tempstr = strndup(str + pmatch[1].rm_so, len); + + if (0 > len) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); + return VC_ERROR_OPERATION_FAILED; + } + tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -2079,7 +2099,12 @@ static int __vc_cmd_dabsolute_check(const char *str, struct tm *td, int *exist) if (!m_flag) return -1; len = pmatch[2].rm_eo - pmatch[2].rm_so; - tempstr = strndup(str + pmatch[2].rm_so, len); + + if (0 > len) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); + return VC_ERROR_OPERATION_FAILED; + } + tempstr = strndup(str + pmatch[2].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); diff --git a/common/vc_config_parser.c b/common/vc_config_parser.c index 050d697..eb9c867 100644 --- a/common/vc_config_parser.c +++ b/common/vc_config_parser.c @@ -225,6 +225,8 @@ int vc_parser_free_engine_info(vc_engine_info_s* engine_info) } } + g_slist_free(engine_info->languages); + if (NULL != engine_info) free(engine_info); return 0; diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 770ca29..566e83b 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -145,6 +145,20 @@ int vc_cmd_parser_append_commands(int pid, vc_cmd_type_e type, vc_cmd_list_h vc_ return ret; } +void __vc_info_parser_demandable_client_free(void* data) +{ + vc_demandable_client_s* d_client = (vc_demandable_client_s*)data; + + if (NULL != d_client) { + if (NULL != d_client->appid) { + free(d_client->appid); + d_client->appid = NULL; + } + + free(d_client); + } +} + int vc_info_parser_get_demandable_clients(GSList** client_list) { /* Check file */ @@ -193,7 +207,7 @@ int vc_info_parser_get_demandable_clients(GSList** client_list) SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Memory alloc error!!"); if (NULL != temp_client_list) { - g_slist_free_full(temp_client_list, free); + g_slist_free_full(temp_client_list, __vc_info_parser_demandable_client_free); temp_client_list = NULL; } xmlFree(key); diff --git a/include/voice_control.h b/include/voice_control.h index d8ccd26..154dce9 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -231,7 +231,7 @@ int vc_get_state(vc_state_e* state); * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * @pre The state should be #VC_STATE_READY. + * @pre The state should be #VC_STATE_READY. * @see vc_request_start() * @see vc_request_stop() * @see vc_request_cancel() diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 3d9ec29..8166f36 100755 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -170,10 +170,29 @@ int vcd_engine_agent_release() /* Get handle data from list */ data = iter->data; iter = g_list_remove(iter, data); + + if (NULL != data) { + if (NULL != data->engine_uuid) { + free(data->engine_uuid); + data->engine_uuid = NULL; + } + if (NULL != data->engine_name) { + free(data->engine_name); + data->engine_name = NULL; + } + if (NULL != data->engine_path) { + free(data->engine_path); + data->engine_path = NULL; + } + + free(data); + data = NULL; + } } } g_list_free(iter); + g_engine_list = NULL; /* release current engine data */ if (NULL != g_dynamic_engine.pefuncs) { @@ -1133,7 +1152,3 @@ int __log_enginelist() return 0; } - - - - -- 2.7.4 From e078a081d295e2ca1453352ffccb8e1d3a26b12e Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 6 Mar 2017 15:31:08 +0900 Subject: [PATCH 05/16] Fix dbus connection free Change-Id: I6919a56db1e341be51373c9aa0b66e4cd55bac42 Signed-off-by: Wonnam Jang (cherry picked from commit 18bc92d77bec4a6784e8ea782383140fe9d501c5) --- client/vc_dbus.c | 41 +++++++++++++++++++++++++++++++++-------- client/vc_mgr_dbus.c | 41 +++++++++++++++++++++++++++++++++-------- client/vc_widget_dbus.c | 41 +++++++++++++++++++++++++++++++++-------- 3 files changed, 99 insertions(+), 24 deletions(-) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 27f4d54..1836396 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -192,6 +192,20 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle return ECORE_CALLBACK_PASS_ON; } +static void __vc_dbus_connection_free() +{ + if (NULL != g_conn_listener) { + dbus_connection_close(g_conn_listener); + dbus_connection_unref(g_conn_listener); + g_conn_listener = NULL; + } + if (NULL != g_conn_sender) { + dbus_connection_close(g_conn_sender); + dbus_connection_unref(g_conn_sender); + g_conn_sender = NULL; + } +} + int vc_dbus_open_connection() { if (NULL != g_conn_sender && NULL != g_conn_listener) { @@ -227,6 +241,7 @@ int vc_dbus_open_connection() if (NULL == g_conn_listener) { SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection "); + __vc_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } @@ -248,11 +263,13 @@ int vc_dbus_open_connection() if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { SLOG(LOG_ERROR, TAG_VCC, "fail dbus_bus_request_name()"); + __vc_dbus_connection_free(); return -2; } if (NULL != g_fd_handler) { SLOG(LOG_WARN, TAG_VCC, "The handler already exists."); + __vc_dbus_connection_free(); return 0; } @@ -266,12 +283,14 @@ int vc_dbus_open_connection() if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); dbus_error_free(&err); + __vc_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } int fd = 0; if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { SLOG(LOG_ERROR, TAG_VCC, "fail to get fd from dbus "); + __vc_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_DEBUG, TAG_VCC, "Get fd from dbus : %d", fd); @@ -280,6 +299,7 @@ int vc_dbus_open_connection() g_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_fd_handler) { SLOG(LOG_ERROR, TAG_VCC, "fail to get fd handler from ecore "); + __vc_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } @@ -309,20 +329,25 @@ int vc_dbus_close_connection() dbus_error_free(&err); } - dbus_connection_close(g_conn_sender); - dbus_connection_close(g_conn_listener); - - dbus_connection_unref(g_conn_sender); - dbus_connection_unref(g_conn_listener); - - g_conn_sender = NULL; - g_conn_listener = NULL; + __vc_dbus_connection_free(); return 0; } int vc_dbus_reconnect() { + if (!g_conn_sender || !g_conn_listener) { + vc_dbus_close_connection(); + + if (0 != vc_dbus_open_connection()) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); + return -1; + } + + SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Reconnect"); + return 0; + } + bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); SLOG(LOG_WARN, TAG_VCC, "[DBUS] Sender(%s) Listener(%s)", diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 7133c92..fe4ad31 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -496,6 +496,20 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd return ECORE_CALLBACK_PASS_ON; } +static void __vc_mgr_dbus_connection_free() +{ + if (NULL != g_m_conn_listener) { + dbus_connection_close(g_m_conn_listener); + dbus_connection_unref(g_m_conn_listener); + g_m_conn_listener = NULL; + } + if (NULL != g_m_conn_sender) { + dbus_connection_close(g_m_conn_sender); + dbus_connection_unref(g_m_conn_sender); + g_m_conn_sender = NULL; + } +} + int vc_mgr_dbus_open_connection() { if (NULL != g_m_conn_sender && NULL != g_m_conn_listener) { @@ -532,6 +546,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(); return VC_ERROR_OPERATION_FAILED; } @@ -547,11 +562,13 @@ 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; } if (NULL != g_m_fd_handler) { SLOG(LOG_WARN, TAG_VCM, "The handler already exists."); + __vc_mgr_dbus_connection_free(); return 0; } @@ -565,12 +582,14 @@ int vc_mgr_dbus_open_connection() if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); dbus_error_free(&err); + __vc_mgr_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } int fd = 0; 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(); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_DEBUG, TAG_VCM, "Get fd from dbus : %d", fd); @@ -580,6 +599,7 @@ 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(); return VC_ERROR_OPERATION_FAILED; } @@ -609,20 +629,25 @@ int vc_mgr_dbus_close_connection() dbus_error_free(&err); } - dbus_connection_close(g_m_conn_sender); - dbus_connection_close(g_m_conn_listener); - - dbus_connection_unref(g_m_conn_sender); - dbus_connection_unref(g_m_conn_listener); - - g_m_conn_sender = NULL; - g_m_conn_listener = NULL; + __vc_mgr_dbus_connection_free(); return 0; } int vc_mgr_dbus_reconnect() { + if (!g_m_conn_sender || !g_m_conn_listener) { + vc_mgr_dbus_close_connection(); + + if (0 != vc_mgr_dbus_open_connection()) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to reconnect"); + return -1; + } + + SLOG(LOG_DEBUG, TAG_VCM, "[DBUS] Reconnect"); + return 0; + } + bool sender_connected = dbus_connection_get_is_connected(g_m_conn_sender); bool listener_connected = dbus_connection_get_is_connected(g_m_conn_listener); diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index 56937b4..18dbe2c 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -268,6 +268,20 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd return ECORE_CALLBACK_PASS_ON; } +static void __vc_mgr_dbus_connection_free() +{ + if (NULL != g_w_conn_listener) { + dbus_connection_close(g_w_conn_listener); + dbus_connection_unref(g_w_conn_listener); + g_w_conn_listener = NULL; + } + if (NULL != g_w_conn_sender) { + dbus_connection_close(g_w_conn_sender); + dbus_connection_unref(g_w_conn_sender); + g_w_conn_sender = NULL; + } +} + int vc_widget_dbus_open_connection() { if (NULL != g_w_conn_sender && NULL != g_w_conn_listener) { @@ -303,6 +317,7 @@ int vc_widget_dbus_open_connection() if (NULL == g_w_conn_listener) { SLOG(LOG_ERROR, TAG_VCW, "Fail to get dbus connection "); + __vc_mgr_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } @@ -324,11 +339,13 @@ int vc_widget_dbus_open_connection() if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { SLOG(LOG_ERROR, TAG_VCW, "fail dbus_bus_request_name()"); + __vc_mgr_dbus_connection_free(); return -2; } if (NULL != g_w_fd_handler) { SLOG(LOG_WARN, TAG_VCW, "The handler already exists."); + __vc_mgr_dbus_connection_free(); return 0; } @@ -342,12 +359,14 @@ int vc_widget_dbus_open_connection() if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message); dbus_error_free(&err); + __vc_mgr_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } int fd = 0; if (1 != dbus_connection_get_unix_fd(g_w_conn_listener, &fd)) { SLOG(LOG_ERROR, TAG_VCW, "fail to get fd from dbus "); + __vc_mgr_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } else { SLOG(LOG_DEBUG, TAG_VCW, "Get fd from dbus : %d", fd); @@ -357,6 +376,7 @@ int vc_widget_dbus_open_connection() if (NULL == g_w_fd_handler) { SLOG(LOG_ERROR, TAG_VCW, "fail to get fd handler from ecore "); + __vc_mgr_dbus_connection_free(); return VC_ERROR_OPERATION_FAILED; } @@ -386,20 +406,25 @@ int vc_widget_dbus_close_connection() dbus_error_free(&err); } - dbus_connection_close(g_w_conn_sender); - dbus_connection_close(g_w_conn_listener); - - dbus_connection_unref(g_w_conn_sender); - dbus_connection_unref(g_w_conn_listener); - - g_w_conn_sender = NULL; - g_w_conn_listener = NULL; + __vc_mgr_dbus_connection_free(); return 0; } int vc_widget_dbus_reconnect() { + if (!g_w_conn_sender || !g_w_conn_listener) { + vc_widget_dbus_close_connection(); + + if (0 != vc_widget_dbus_open_connection()) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to reconnect"); + return -1; + } + + SLOG(LOG_DEBUG, TAG_VCW, "[DBUS] Reconnect"); + return 0; + } + bool sender_connected = dbus_connection_get_is_connected(g_w_conn_sender); bool listener_connected = dbus_connection_get_is_connected(g_w_conn_listener); SLOG(LOG_DEBUG, TAG_VCW, "[DBUS] Sender(%s) Listener(%s)", -- 2.7.4 From 87db3f658e9eb08702d5dd7f7bf21f88d28f2537 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 8 Mar 2017 11:27:00 +0900 Subject: [PATCH 06/16] Add setting handle check to prevent duplicated deinitilize request Change-Id: I9d90a00a47cd055e52e361078a908a79a9ea5fd2 (cherry picked from commit 39817d7e7b505f4dbe3faec8e72c58daabebee95) --- client/vc_setting.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/vc_setting.c b/client/vc_setting.c index 28de295..3f35bb3 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -96,6 +96,7 @@ int vc_setting_initialize(void) SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to initialize config manager"); SLOG(LOG_DEBUG, TAG_VCS, "====="); SLOG(LOG_DEBUG, TAG_VCS, " "); + vc_config_mgr_finalize(getpid() + VC_SETTING_CONFIG_HANDLE); return VC_ERROR_OPERATION_FAILED; } @@ -113,6 +114,13 @@ int vc_setting_deinitialize() { SLOG(LOG_DEBUG, TAG_VCS, "===== Deinitialize VC Setting"); + if (VC_SETTING_STATE_READY != g_state) { + SLOG(LOG_WARN, TAG_VCS, "[WARNING] VC Setting is not initialized"); + SLOG(LOG_DEBUG, TAG_VCS, "====="); + SLOG(LOG_DEBUG, TAG_VCS, " "); + return VC_ERROR_INVALID_STATE; + } + vc_config_mgr_unset_lang_cb(getpid() + VC_SETTING_CONFIG_HANDLE); vc_config_mgr_finalize(getpid() + VC_SETTING_CONFIG_HANDLE); -- 2.7.4 From 9ee3fb6e5f84dc7d2ef1cdf367ec4a3a1400a751 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Thu, 16 Mar 2017 17:12:26 +0900 Subject: [PATCH 07/16] Set result text before selecting result when conflict status is Change-Id: If30af9e0b8d262888f9af4da06ab2f8a58fbd298 Signed-off-by: Wonnam Jang --- client/vc_mgr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 4560dff..cfea1e3 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -2078,6 +2078,8 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) bool cb_ret; + vc_mgr_client_set_all_result(g_vc_m, event, temp_text); + vc_mgr_client_use_callback(g_vc_m); cb_ret = all_callback(event, vc_cmd_list, temp_text, temp_message, all_user_data); vc_mgr_client_not_use_callback(g_vc_m); @@ -2112,7 +2114,6 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) int count = 0; vc_cmd_list_get_count(vc_cmd_list, &count); if (0 < count) { - vc_mgr_client_set_all_result(g_vc_m, event, temp_text); if (true == cb_ret) { SLOG(LOG_DEBUG, TAG_VCM, "Callback result is true"); if (VC_RESULT_TYPE_NOTIFICATION != result_type) -- 2.7.4 From 5614bbd09b7fc3fc9ca7d2e635b58d09df6d87cc Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Fri, 17 Mar 2017 17:17:21 +0900 Subject: [PATCH 08/16] Get focused pid to set foreground Change-Id: I73848b36bb8472b1bcd4ec364607a27c22e84c63 Signed-off-by: Wonnam Jang --- server/vcd_client_data.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 9b2a00f..b033950 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -16,6 +16,7 @@ #include #include +#include #include "vcd_client_data.h" #include "vcd_config.h" @@ -1396,9 +1397,14 @@ void vcd_client_update_foreground_pid() { int tmp_pid = VC_RUNTIME_INFO_NO_FOREGROUND; vcd_config_get_foreground(&tmp_pid); - SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", tmp_pid); - char appid[255] = {'\0',}; + int pid = VC_RUNTIME_INFO_NO_FOREGROUND; + int ret = aul_window_get_focused_pid(&pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get focused pid, ret(%d)", ret); + } + SLOG(LOG_INFO, TAG_VCD, "[INFO] Foreground pid (%d), Focused pid (%d)", tmp_pid, pid); + GSList *iter = NULL; vc_client_info_s *data = NULL; @@ -1417,10 +1423,7 @@ void vcd_client_update_foreground_pid() if (NULL != data) { SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, data->pid); - memset(appid, 0, 255); - aul_app_get_appid_bypid(data->pid, appid, sizeof(appid)); - int status = aul_app_get_status(appid); - if (status == STATUS_FOCUS) { + if (pid == data->pid) { SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", data->pid); vcd_config_set_foreground(data->pid, true); if (tmp_pid != data->pid) { @@ -1448,10 +1451,7 @@ void vcd_client_update_foreground_pid() if (NULL != widget_data) { SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, widget_data->pid); - memset(appid, 0, 255); - aul_app_get_appid_bypid(widget_data->pid, appid, sizeof(appid)); - int status = aul_app_get_status(appid); - if (status == STATUS_FOCUS) { + if (pid == widget_data->pid) { SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", widget_data->pid); vcd_config_set_foreground(widget_data->pid, true); if (tmp_pid != widget_data->pid) { -- 2.7.4 From e0e37ff8cf6b14dcc68581e7f0294eb88eb8cc75 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 13 Mar 2017 16:00:56 +0900 Subject: [PATCH 09/16] Fix direct leak Change-Id: I51d8fbbaa46a3a318b3e1a3102c0e21269b9690c Signed-off-by: sooyeon.kim (cherry picked from commit b8f1f78a4f93753984e63e7ead6f246da7faf1fe) --- server/vcd_engine_agent.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 8166f36..0c9faa7 100755 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -173,15 +173,15 @@ int vcd_engine_agent_release() if (NULL != data) { if (NULL != data->engine_uuid) { - free(data->engine_uuid); + g_free(data->engine_uuid); data->engine_uuid = NULL; } if (NULL != data->engine_name) { - free(data->engine_name); + g_free(data->engine_name); data->engine_name = NULL; } if (NULL != data->engine_path) { - free(data->engine_path); + g_free(data->engine_path); data->engine_path = NULL; } @@ -266,9 +266,9 @@ int vcd_engine_agent_initialize_current_engine() } else { if (NULL != g_dynamic_engine.engine_uuid) { /* set data from g_engine_list */ - if (g_dynamic_engine.engine_uuid != NULL) free(g_dynamic_engine.engine_uuid); - if (g_dynamic_engine.engine_name != NULL) free(g_dynamic_engine.engine_name); - if (g_dynamic_engine.engine_path != NULL) free(g_dynamic_engine.engine_path); + if (g_dynamic_engine.engine_uuid != NULL) g_free(g_dynamic_engine.engine_uuid); + if (g_dynamic_engine.engine_name != NULL) g_free(g_dynamic_engine.engine_name); + if (g_dynamic_engine.engine_path != NULL) g_free(g_dynamic_engine.engine_path); } g_dynamic_engine.engine_uuid = g_strdup(dynamic_engine->engine_uuid); @@ -419,9 +419,13 @@ int __internal_update_engine_list() data = iter->data; if (NULL != data) { - if (NULL != data->engine_uuid) free(data->engine_uuid); - if (NULL != data->engine_path) free(data->engine_path); - if (NULL != data->engine_name) free(data->engine_name); + if (NULL != data->engine_uuid) g_free(data->engine_uuid); + if (NULL != data->engine_path) g_free(data->engine_path); + if (NULL != data->engine_name) g_free(data->engine_name); + + data->engine_uuid = NULL; + data->engine_path = NULL; + data->engine_name = NULL; free(data); } -- 2.7.4 From 88b4ebf37ce81917f6167985dbb780c488a19153 Mon Sep 17 00:00:00 2001 From: "Park, Sehwan" Date: Wed, 29 Mar 2017 20:50:01 +0900 Subject: [PATCH 10/16] The description related with X window system is changed Change-Id: Id1d12638b54e83af6c118d239aba4bb9425ee50c --- client/vc_widget_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/vc_widget_client.h b/client/vc_widget_client.h index b5c9633..55a44e3 100644 --- a/client/vc_widget_client.h +++ b/client/vc_widget_client.h @@ -31,7 +31,7 @@ typedef struct { vc_h vc; int pid; int uid; /*<< unique id = pid + handle */ - int xid; /*<< main X window id */ + int xid; /*<< main Wayland window id */ vc_result_cb result_cb; void* result_user_data; -- 2.7.4 From c15bb24cec65ecc5987adc862e70edc42ebde2be Mon Sep 17 00:00:00 2001 From: "Park, Sehwan" Date: Wed, 29 Mar 2017 21:48:20 +0900 Subject: [PATCH 11/16] Unused codes and unnecessary variable initializing are removed Change-Id: Ifb50e234008e7c0935c6fd8eb06ef11c50967661 --- client/vc_mgr.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index cfea1e3..5b45991 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -559,33 +559,6 @@ int vc_mgr_set_demandable_client_rule(const char* rule) SLOG(LOG_DEBUG, TAG_VCM, " "); return 0; - - /* - int count = 0; - ret = -1; - while (0 != ret) { - ret = vc_mgr_dbus_request_demandable_client(g_vc_m->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request set client rule to daemon : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request set client rule : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } - } - - SLOG(LOG_DEBUG, TAG_VCM, "====="); - SLOG(LOG_DEBUG, TAG_VCM, " "); - - return 0; - */ } int vc_mgr_unset_demandable_client_rule() @@ -1033,12 +1006,10 @@ int vc_mgr_set_audio_type(const char* audio_id) return VC_ERROR_INVALID_STATE; } - int ret; + int ret = -1; int count = 0; /* Request */ - ret = -1; - count = 0; while (0 != ret) { ret = vc_mgr_dbus_request_set_audio_type(g_vc_m->handle, audio_id); if (0 != ret) { -- 2.7.4 From 51bd4ceb583eb41218bbc62fcdc9fe0445314060 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Mon, 6 Mar 2017 15:19:17 +0900 Subject: [PATCH 12/16] Add command list handle check logic Change-Id: I5a258cbdd2761cb6c99e14b38f72f33e02e8a375 --- client/vc.c | 5 +++++ client/vc_mgr.c | 15 +++++++++++++++ common/vc_command.c | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) mode change 100755 => 100644 common/vc_command.c diff --git a/client/vc.c b/client/vc.c index 345dfaf..75b930e 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1056,6 +1056,11 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) vc_cmd_list_s* list = NULL; list = (vc_cmd_list_s*)vc_cmd_list; + if (NULL == list->list) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command list"); + return VC_ERROR_INVALID_PARAMETER; + } + int ret = 0; char* invocation_name = NULL; if (VC_COMMAND_TYPE_BACKGROUND == type) { diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 2001006..4609a1a 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -792,8 +792,19 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) return VC_ERROR_INVALID_STATE; } + if (NULL == vc_cmd_list) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + vc_cmd_list_s* list = NULL; list = (vc_cmd_list_s*)vc_cmd_list; + SLOG(LOG_INFO, TAG_VCM, "[List] (%p) (%p)", list, list->list); + + if (NULL == list->list) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid command list"); + return VC_ERROR_INVALID_PARAMETER; + } int i; int ret; @@ -1723,6 +1734,10 @@ int vc_mgr_start(bool exclusive_command_option) } } + g_volume_db = 0; + g_prev_volume_db = 0; + g_cur_volume_db = 0; + SLOG(LOG_DEBUG, TAG_VCM, "====="); SLOG(LOG_DEBUG, TAG_VCM, " "); diff --git a/common/vc_command.c b/common/vc_command.c old mode 100755 new mode 100644 index b085344..49f0edc --- a/common/vc_command.c +++ b/common/vc_command.c @@ -366,7 +366,7 @@ int vc_cmd_list_remove_all(vc_cmd_list_h vc_cmd_list, bool release_command) } } } - + list->list = NULL; list->index = -1; SLOG(LOG_DEBUG, TAG_VCCMD, "====="); -- 2.7.4 From 87a0c3e05f31dc546f8cdafe8c6a185f68285c3c Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 5 Apr 2017 18:26:06 +0900 Subject: [PATCH 13/16] Update url link Change-Id: Id60a547ac2a04d21749ce686b27032e6a5bac315 Signed-off-by: Wonnam Jang (cherry picked from commit 7e1ac460467e1f0e073762b4d8c9a403762270b7) --- doc/uix_vc_doc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/uix_vc_doc.h b/doc/uix_vc_doc.h index 040b006..771f326 100644 --- a/doc/uix_vc_doc.h +++ b/doc/uix_vc_doc.h @@ -197,7 +197,7 @@ * It is recommended to design feature related codes in your application for reliability.
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.
* To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
- * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature Element. */ -- 2.7.4 From 3e48f6c59b224e35fc206e201a721de2ba16caf3 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 11 Apr 2017 15:38:58 +0900 Subject: [PATCH 14/16] Use license macro in .spec file Change-Id: I3c3e50f372350c7a8c36b6cb7e96838409448ec2 Signed-off-by: Suyeon Hwang --- packaging/voice-control.spec | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index be8e8a0..25c0471 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -102,8 +102,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} -mkdir -p %{buildroot}%{TZ_SYS_RO_SHARE}/license -install LICENSE %{buildroot}%{TZ_SYS_RO_SHARE}/license/%{name} %make_install @@ -115,6 +113,7 @@ mkdir -p %{_libdir}/voice/vc %postun -p /sbin/ldconfig %files +%license LICENSE %manifest %{name}.manifest %defattr(-,root,root,-) %{_libdir}/libvc.so @@ -125,7 +124,6 @@ mkdir -p %{_libdir}/voice/vc %{TZ_SYS_RO_SHARE}/upgrade/scripts/502.vc_upgrade_24to30.sh %{TZ_SYS_RO_SHARE}/voice/vc/1.0/vc-config.xml %{TZ_SYS_RO_SHARE}/dbus-1/services/org.tizen.voice* -%{TZ_SYS_RO_SHARE}/license/%{name} /etc/dbus-1/session.d/vc-server.conf %files devel -- 2.7.4 From 6304a412ac3bd88bb362dab4bfecee0e8f9ed84a Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 12 Apr 2017 10:51:23 +0900 Subject: [PATCH 15/16] Fix calling duplicated result callback Change-Id: I3c1b2a49bb2aa1d0e795c1811a4d1ccee83cc12b Signed-off-by: Suyeon Hwang --- common/vc_cmd_db.c | 8 +++----- server/vcd_server.c | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 4218894..30e0266 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -989,7 +989,8 @@ int __vc_db_get_result_pid_list(const char* result, GSList** pid_list) int ret = 0; sqlite3_stmt* stmt = NULL; - const char* sql = "SELECT * FROM vc_result WHERE result = ? COLLATE NOCASE;"; + const char* sql = "SELECT DISTINCT pid, type FROM vc_result WHERE result = ? COLLATE NOCASE ORDER BY pid ASC;"; + ret = sqlite3_prepare_v2(db_handle, sql, -1, &stmt, NULL); if (ret != SQLITE_OK) { @@ -1031,12 +1032,9 @@ int __vc_db_get_result_pid_list(const char* result, GSList** pid_list) } temp = sqlite3_column_int(stmt, 0); - temp_cmd->id = temp; - - temp = sqlite3_column_int(stmt, 5); temp_cmd->pid = temp; - temp = sqlite3_column_int(stmt, 6); + temp = sqlite3_column_int(stmt, 1); temp_cmd->type = temp; temp_pid_list = g_slist_append(temp_pid_list, temp_cmd); diff --git a/server/vcd_server.c b/server/vcd_server.c index de53304..26f4b7c 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -387,12 +387,14 @@ static Eina_Bool __vcd_send_selected_result(void *data) GSList* iter = NULL; vc_cmd_s* temp_cmd = NULL; int ret = 0; + int pre_pid = -1; + int pre_type = -1; iter = g_slist_nth(pid_list, 0); while (NULL != iter) { temp_cmd = iter->data; - if (NULL != temp_cmd) { + if (NULL != temp_cmd && (pre_pid != temp_cmd->pid || pre_type == VC_COMMAND_TYPE_WIDGET || temp_cmd->type == VC_COMMAND_TYPE_WIDGET)) { /* Launch deactivated several apps that is matched with result */ ret = __vcd_launch_app(result); if (0 != ret) { @@ -405,6 +407,8 @@ static Eina_Bool __vcd_send_selected_result(void *data) break; } else { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type); + pre_pid = temp_cmd->pid; + pre_type = temp_cmd->type; } } free(temp_cmd); -- 2.7.4 From c9f8884299559c7b73b5c047607f92a185be584b Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 29 Mar 2017 10:52:19 +0900 Subject: [PATCH 16/16] Fix event of consumed ASR result to become success Change-Id: I153ea61d8b7245c729459ac72f74f18032cd5008 Signed-off-by: Suyeon Hwang --- server/vcd_server.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/vcd_server.c b/server/vcd_server.c index 26f4b7c..aff998d 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -31,6 +31,7 @@ #include "vcd_dbus.h" #include "voice_control_command_expand.h" +#include "voice_control_common.h" /* * VC Server static variable @@ -510,12 +511,17 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int vcdc_send_show_tooltip(pid, false); if (-1 != vcd_client_manager_get_pid()) { /* Manager client is available */ + vc_info_parser_unset_result(false); + vc_info_parser_set_result(all_result, VC_RESULT_EVENT_RESULT_SUCCESS, msg, NULL, false); if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result"); } } vcd_client_manager_set_exclusive(false); + + vcd_config_set_service_state(VCD_STATE_READY); + vcdc_send_service_state(VCD_STATE_READY); return; } } -- 2.7.4