Fix memory leak of ecore timer 93/123393/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 19 Jan 2017 08:35:39 +0000 (17:35 +0900)
committerKwangyoun Kim <ky85.kim@samsung.com>
Wed, 5 Apr 2017 10:21:00 +0000 (03:21 -0700)
Change-Id: I4a884582b76c7fec294b6654a9456ebcc1652215
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
(cherry picked from commit cd080b4f4e38f40d86ed7372348012bf0383bd88)

server/sttd_server.c
server/stte.c

index 5b4e046..f364cf3 100755 (executable)
 #include "sttd_recorder.h"
 #include "sttd_server.h"
 
+
+#define CLIENT_CLEAN_UP_TIME 500
+
+
 static pthread_mutex_t stte_result_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t stte_result_time_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -35,6 +39,7 @@ static double g_processing_timeout = 30;
 
 static double g_recording_timeout = 60;
 
+static Ecore_Timer* g_check_client_timer = NULL;
 Ecore_Timer*   g_recording_timer = NULL;
 Ecore_Timer*   g_processing_timer = NULL;
 
@@ -477,6 +482,11 @@ int sttd_initialize(stte_request_callback_s *callback)
                return ret;
        }
 
+       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, sttd_cleanup_client, NULL);
+       if (NULL == g_check_client_timer) {
+               SLOG(LOG_WARN, TAG_STTD, "[Main Warning] Fail to create timer of client check");
+       }
+
        SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] initialize");
 
        return 0;
@@ -507,6 +517,13 @@ int sttd_finalize()
 
        sttd_engine_agent_release();
 
+       if (NULL != g_check_client_timer) {
+               ecore_timer_del(g_check_client_timer);
+               g_check_client_timer = NULL;
+
+               SLOG(LOG_INFO, TAG_STTD, "[INFO] Delete ecore timer handle");
+       }
+
        return STTD_ERROR_NONE;
 }
 
index 89d4be0..2a00e12 100755 (executable)
 #include "stte.h"
 
 
-#define CLIENT_CLEAN_UP_TIME 500
-
-static Ecore_Timer* g_check_client_timer = NULL;
-
 int stte_main(int argc, char**argv, stte_request_callback_s *callback)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Start engine");
@@ -53,11 +49,6 @@ int stte_main(int argc, char**argv, stte_request_callback_s *callback)
 
        stt_network_initialize();
 
-       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, sttd_cleanup_client, NULL);
-       if (NULL == g_check_client_timer) {
-               SLOG(LOG_WARN, TAG_STTD, "[Main Warning] Fail to create timer of client check");
-       }
-
        SLOG(LOG_DEBUG, TAG_STTD, "[Main] stt-service start...");
 
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
@@ -124,4 +115,4 @@ int stte_set_private_data_requested_cb(stte_private_data_requested_cb callback)
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send speech status");
        }
        return ret;
-}
+}
\ No newline at end of file