fix a defect of app2sd-server termination before processing is done.
[platform/core/appfw/app2sd.git] / plugin / app2sd / src / app2sd_server.c
index 0c0af15..04afa1e 100644 (file)
 
 #define APPFW_UID 301
 
+int processing_busy_cnt;
+
 GMainLoop *app2sd_mainloop = NULL;
 
 gboolean __exit_app2sd_server(void *data)
 {
-       _D("exit app2sd_server");
-
-       g_main_loop_quit(app2sd_mainloop);
+       if (processing_busy_cnt <= 0) {
+               _D("exit app2sd_server");
+               g_main_loop_quit(app2sd_mainloop);
+               return FALSE;
+       }
 
-       return FALSE;
+       _D("processing busy, count(%d)", processing_busy_cnt);
+       return TRUE;
 }
 
 static int __app2sd_get_sender_unixinfo(GDBusConnection *conn,
@@ -716,6 +721,8 @@ static void handle_method_call(GDBusConnection *connection,
 {
        uid_t sender_uid = -1;
 
+       processing_busy_cnt++;
+
        sender_uid = (uid_t)__app2sd_get_sender_uid(connection, sender);
 
        if (g_strcmp0(method_name, "PreAppInstall") == 0) {
@@ -760,6 +767,7 @@ static void handle_method_call(GDBusConnection *connection,
        }
 
        g_timeout_add_seconds(5, __exit_app2sd_server, NULL);
+       processing_busy_cnt--;
 }
 
 static const GDBusInterfaceVTable interface_vtable = {
@@ -826,8 +834,6 @@ static int __app2sd_server_init()
                return -1;
        }
 
-       /* add timer */
-
        return 0;
 }