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 0e61f8f..3b99caf 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 9bdcf06..3e27ec2 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 6ca4527..ac0ddc5 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 02fb817..44a1972 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 6dd2e93..539a2a1 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 e828415..f5045a8 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;