From 579fd4775dea14eade35dcbbd06c80f124f75092 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 19 Jan 2017 17:59:18 +0900 Subject: [PATCH] Fix memory leak of ecore timer Change-Id: I2a8a09d69a7639603048f847d0e966b54e241f73 Signed-off-by: Suyeon Hwang (cherry picked from commit f0c6656f744a0547443579ffa757c8ea08560a8c) --- server/ttsd_server.c | 21 +++++++++++++++++---- server/ttse.c | 11 +---------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/server/ttsd_server.c b/server/ttsd_server.c index 5a657a5..afdff96 100755 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -25,6 +25,9 @@ #include "ttsd_server.h" +#define CLIENT_CLEAN_UP_TIME 500 + + typedef enum { TTSD_SYNTHESIS_CONTROL_DOING = 0, TTSD_SYNTHESIS_CONTROL_DONE = 1, @@ -42,6 +45,7 @@ typedef struct { /* If engine is running */ static ttsd_synthesis_control_e g_synth_control; +static Ecore_Timer* g_check_client_timer = NULL; static Ecore_Timer* g_wait_timer = NULL; static utterance_t g_utt; @@ -198,7 +202,6 @@ int ttsd_send_error(ttse_error_e error, const char* msg) } int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data) - { SLOG(LOG_DEBUG, tts_tag(), "===== SEND SYNTHESIS RESULT START"); @@ -466,6 +469,11 @@ int ttsd_initialize(ttse_request_callback_s *callback) ttsd_config_set_screen_reader_callback(__screen_reader_changed_cb); } + g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL); + if (NULL == g_check_client_timer) { + SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to create timer"); + } + return TTSD_ERROR_NONE; } @@ -487,6 +495,13 @@ int ttsd_finalize() ttsd_engine_agent_release(); + if (NULL != g_check_client_timer) { + ecore_timer_del(g_check_client_timer); + g_check_client_timer = NULL; + + SLOG(LOG_INFO, tts_tag(), "[INFO] Delete ecore timer handle"); + } + return TTSD_ERROR_NONE; } @@ -521,12 +536,10 @@ int ttsd_server_initialize(int pid, int uid, bool* credential_needed) static Eina_Bool __quit_ecore_loop(void *data) { ttsd_dbus_close_connection(); - ttsd_network_finalize(); - ttsd_finalize(); - ecore_main_loop_quit(); + return EINA_FALSE; } diff --git a/server/ttse.c b/server/ttse.c index 01eb7f0..44b61c1 100755 --- a/server/ttse.c +++ b/server/ttse.c @@ -24,10 +24,6 @@ #include "ttse.h" -#define CLIENT_CLEAN_UP_TIME 500 - -static Ecore_Timer* g_check_client_timer = NULL; - static ttsd_mode_e g_tts_mode = TTSD_MODE_DEFAULT; const char* tts_tag() @@ -109,11 +105,6 @@ int ttse_main(int argc, char** argv, ttse_request_callback_s *callback) SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to initialize network"); } - g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL); - if (NULL == g_check_client_timer) { - SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to create timer"); - } - SLOG(LOG_DEBUG, tts_tag(), "===="); SLOG(LOG_DEBUG, tts_tag(), ""); @@ -213,4 +204,4 @@ int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_f } return ret; -} +} \ No newline at end of file -- 2.7.4