Fix PLM issue(P130121-3243) and Add Daemon termination
authorKwangyoun Kim <ky85.kim@samsung.com>
Thu, 24 Jan 2013 09:09:57 +0000 (18:09 +0900)
committerKwangyoun Kim <ky85.kim@samsung.com>
Thu, 24 Jan 2013 09:09:57 +0000 (18:09 +0900)
Change-Id: Ia4eaff0240c2374971f2a90fae38d356061b698d

client/tts.c
client/tts_setting.c
debian/changelog
server/ttsd_engine_agent.c
server/ttsd_main.c
server/ttsd_server.cpp

index 0e61f8feb08e809d178b85f9342ea4bc7c34ce6b..3b99cafaa4d8acb0c4255e4b2095aff47e0fea42 100755 (executable)
@@ -97,7 +97,8 @@ int tts_destroy(tts_h tts)
                ret = tts_dbus_request_finalize(client->uid);
                if (0 != ret) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request finalize");
-               }   
+               }
+               g_is_daemon_started = false;
        case TTS_STATE_CREATED:
                /* Free resources */
                tts_client_destroy(tts);
@@ -235,6 +236,7 @@ int tts_unprepare(tts_h tts)
        if (0 != ret) {
                SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to request finalize");
        }
+       g_is_daemon_started = false;
 
        client->before_state = client->current_state;
        client->current_state = TTS_STATE_CREATED;
@@ -1056,41 +1058,14 @@ static bool _tts_is_alive()
        return FALSE;
 }
 
-
-static void __my_sig_child(int signo, siginfo_t *info, void *data)
-{
-       int status;
-       pid_t child_pid, child_pgid;
-
-       child_pgid = getpgid(info->si_pid);
-       SLOG(LOG_DEBUG, TAG_TTSC, "Signal handler: dead pid = %d, pgid = %d", info->si_pid, child_pgid);
-
-       while (0 < (child_pid = waitpid(-1, &status, WNOHANG))) {
-               if(child_pid == child_pgid)
-                       killpg(child_pgid, SIGKILL);
-       }
-
-       return;
-}
-
 static int __tts_check_tts_daemon()
 {
-       if (TRUE == _tts_is_alive())
+       if (TRUE == _tts_is_alive()) {
                return 0;
+       }
        
        /* fork-exec tts-daemom */
        int pid, i;
-       struct sigaction act, dummy;
-
-       act.sa_handler = NULL;
-       act.sa_sigaction = __my_sig_child;
-       sigemptyset(&act.sa_mask);
-       act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
-       
-       if (sigaction(SIGCHLD, &act, &dummy) < 0) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Cannot make a signal handler");
-               return -1;
-       }
 
        pid = fork();
 
index 9bdcf065c83b0a2adf9be953fd2ad38814a4e297..3e27ec299f0137c4f1703595bb1f81f7967f1c6f 100755 (executable)
@@ -184,7 +184,8 @@ int tts_setting_finalize()
 
                return TTS_SETTING_ERROR_OPERATION_FAILED;
        }
-
+       g_is_daemon_started = false;
+       
        if (0 != tts_setting_dbus_close_connection()) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection\n ");
        } else {
@@ -589,22 +590,6 @@ static bool __tts_setting_is_alive()
 
 }
 
-static void __setting_my_sig_child(int signo, siginfo_t *info, void *data)
-{
-       int status;
-       pid_t child_pid, child_pgid;
-
-       child_pgid = getpgid(info->si_pid);
-       SLOG(LOG_DEBUG, TAG_TTSC, "Signal handler: dead pid = %d, pgid = %d", info->si_pid, child_pgid);
-
-       while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
-               if(child_pid == child_pgid)
-                       killpg(child_pgid, SIGKILL);
-       }
-
-       return;
-}
-
 static int __check_setting_tts_daemon()
 {
        if( TRUE == __tts_setting_is_alive() )
@@ -612,17 +597,6 @@ static int __check_setting_tts_daemon()
 
        /* fork-exec tts-daemom */
        int pid, i;
-       struct sigaction act, dummy;
-
-       act.sa_handler = NULL;
-       act.sa_sigaction = __setting_my_sig_child;
-       sigemptyset(&act.sa_mask);
-       act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
-
-       if (sigaction(SIGCHLD, &act, &dummy) < 0) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Cannot make a signal handler");
-               return -1;
-       }
 
        pid = fork();
 
index 6ca4527c14653e1269644b9a09f3dd4b541aa228..ac0ddc5b8162bdcf1e52ba53b2619d19e436b6ee 100644 (file)
@@ -1,3 +1,10 @@
+tts (0.1.1-44slp2+1) unstable; urgency=low
+
+  * Fix PLM issue(P130121-3243)
+  * Add Daemon termination 
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Thu, 24 Jan 2013 18:08:17 +0900
+
 tts (0.1.1-43slp2+1) unstable; urgency=low
 
   * Change License and notice file
index 02fb817b2e156335425f252e97802be5cf94ce56..44a1972545a78d590bd1e1d54c0ee2efe3f44f9e 100755 (executable)
@@ -155,18 +155,13 @@ int ttsd_engine_agent_release()
        if (g_list_length(g_engine_list) > 0) {
                /* Get a first item */
                iter = g_list_first(g_engine_list);
-
                while (NULL != iter) {
                        /* Get data from item */
                        data = iter->data;
-                       dlclose(data->handle); 
-
                        iter = g_list_remove(iter, data);
                }
        }
-
        g_list_free(iter);
-
        /* release current engine data */
        if (g_cur_engine.pefuncs != NULL)
                g_free(g_cur_engine.pefuncs);
index 6dd2e932eee825a37b6d9c74d361a2d23058a3e8..539a2a1f9ade20b84fb5b7974b82f79127b547d7 100755 (executable)
@@ -59,13 +59,19 @@ int main()
        printf("TTS-Daemon Start...\n");
        
        ecore_main_loop_begin();
-       
-       ecore_shutdown();
 
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== TTS DAEMON FINALIZE");
+       
        ttsd_dbus_close_connection();
 
        ttsd_network_finalize();
 
+       ecore_shutdown();
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+
        return 0;
 }
 
index e828415ddfabcfb1a8bce4320a51db4ac0c1cdec..f5045a8d070a62726b30717f723fc024f1c870a2 100755 (executable)
@@ -495,6 +495,12 @@ int ttsd_server_initialize(int pid, int uid)
        return TTSD_ERROR_NONE;
 }
 
+static Eina_Bool __quit_ecore_loop(void *data)
+{
+       ecore_main_loop_quit();
+       SLOG(LOG_DEBUG, TAG_TTSD, "[Server] quit ecore main loop");
+       return EINA_FALSE;
+}
 
 int ttsd_server_finalize(int uid)
 {
@@ -512,11 +518,13 @@ int ttsd_server_finalize(int uid)
 
        /* unload engine, if ref count of client is 0 */
        if (0 == ttsd_data_get_client_count()) {
-               if (0 != ttsd_engine_agent_unload_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to unload current engine ");
+               if (0 != ttsd_engine_agent_release()) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to release engine agent");
                } else {
-                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] unload current engine ");
+                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] release engine agent");
                }
+
+               ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
 
        return TTSD_ERROR_NONE;
@@ -794,10 +802,12 @@ int ttsd_server_setting_finalize(int uid)
        /* unload engine, if ref count of client is 0 */
        if (0 == ttsd_data_get_client_count())
        {
-               if (0 != ttsd_engine_agent_unload_current_engine()) 
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to unload current engine ");
-               else
-                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting SUCCESS] unload current engine ");
+               if (0 != ttsd_engine_agent_release()) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to release engine agent");
+               } else {
+                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting SUCCESS] Release engine agent");
+               }
+               ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
 
        return TTSD_ERROR_NONE;