Add a checker whether quit_loop_timer is carried out or not 22/265922/1
authorsooyeon <sooyeon.kim@samsung.com>
Tue, 2 Nov 2021 10:40:18 +0000 (19:40 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Tue, 2 Nov 2021 10:40:18 +0000 (19:40 +0900)
Change-Id: I2b875ea42ef0a9c5e4db1b4707639f3860a2ebc7
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
server/ttsd_server.c

index 8f01e230bccc7e500f416c73dbbe7e7c92c0dc3a..21c3808fbd873d616b0b7e26ec3328cc35438ff1 100644 (file)
@@ -51,6 +51,7 @@ typedef struct {
 static Ecore_Timer* g_check_client_timer = NULL;
 static Ecore_Timer* g_wait_timer = NULL;
 static Ecore_Timer* g_terminate_timer = NULL;
+static Ecore_Timer* g_quit_loop_timer = NULL;
 
 static utterance_t g_utt;
 
@@ -568,12 +569,18 @@ int ttsd_finalize()
                SLOG(LOG_INFO, tts_tag(), "[INFO] Delete ecore terminating timer handle");
        }
 
-       if (NULL != g_check_client_timer) {
+       if (g_check_client_timer) {
                ecore_timer_del(g_check_client_timer);
                g_check_client_timer = NULL;
                SLOG(LOG_INFO, tts_tag(), "[INFO] Delete ecore checking client timer handle");
        }
 
+       if (g_quit_loop_timer) {
+               ecore_timer_del(g_quit_loop_timer);
+               g_quit_loop_timer = NULL;
+               SLOG(LOG_INFO, tts_tag(), "[INFO] Delete ecore quit loop timer handle");
+       }
+
        return TTSD_ERROR_NONE;
 }
 
@@ -762,7 +769,10 @@ Eina_Bool ttsd_cleanup_client(void *data)
        if (0 < ttsd_data_get_client_count()) {
                ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
        } else {
-               ecore_timer_add(0, __quit_ecore_loop, NULL);
+               if (NULL == g_quit_loop_timer) {
+                       SLOG(LOG_INFO, tts_tag(), "[Server] Add a timer __quit_ecore_loop");
+                       g_quit_loop_timer = ecore_timer_add(0, __quit_ecore_loop, NULL);
+               }
                SLOG(LOG_ERROR, tts_tag(), "[Server] Deleted timer");
                g_check_client_timer = NULL;
                return EINA_FALSE;
@@ -806,8 +816,12 @@ int ttsd_server_finalize(int uid)
 
        /* unload engine, if ref count of client is 0 */
        if (0 == ttsd_data_get_client_count()) {
-               SLOG(LOG_DEBUG, tts_tag(), "[Server] Quit main loop");
-               ecore_timer_add(0, __quit_ecore_loop, NULL);
+               if (NULL == g_quit_loop_timer) {
+                       SLOG(LOG_DEBUG, tts_tag(), "[Server] Quit main loop");
+                       g_quit_loop_timer = ecore_timer_add(0, __quit_ecore_loop, NULL);
+               } else {
+                       SLOG(LOG_WARN, tts_tag(), "[Server] Already called __quit_ecore_loop");
+               }
        }
 
        return TTSD_ERROR_NONE;