Fix AUL Request Handler 09/229409/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 1 Apr 2020 02:16:56 +0000 (11:16 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 1 Apr 2020 02:16:56 +0000 (11:16 +0900)
If the caller waits the result, AUL request handler replies in the
dispatch function. If the calle application is not responding, the caller
application gets the error from AMD.

Change-Id: Ibbfe03f05fd53ce44f2dfd49968858323d559b87
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/aul_launch.c

index 6a3924e..3c9a7f4 100644 (file)
@@ -309,6 +309,7 @@ static struct aul_request_s *__create_request(int cmd, int clifd, bundle *b)
 static gboolean __dispatch_request(gpointer data)
 {
        struct aul_request_s *req = (struct aul_request_s *)data;
+       int ret;
 
        if (!__context.initialized) {
                _W("Ignore request(%d)", req->cmd);
@@ -317,6 +318,20 @@ static gboolean __dispatch_request(gpointer data)
        }
 
        aul_worker_remove_anr_timer(__context.worker);
+
+       if (req->cmd != WIDGET_GET_CONTENT && req->clifd > 0) {
+               ret = aul_sock_send_result(req->clifd, 0);
+               if (ret < 0) {
+                       _E("Failed to send result. cmd(%s:%d)",
+                                       aul_cmd_convert_to_string(req->cmd),
+                                       req->cmd);
+                       __destroy_request(req);
+                       return G_SOURCE_REMOVE;
+               }
+
+               req->clifd = -1;
+       }
+
        if (req->cmd >= APP_START && req->cmd < ARRAY_SIZE(__dispatcher) &&
                        __dispatcher[req->cmd]) {
                _W("Command(%s:%d)",
@@ -340,7 +355,6 @@ static bool __worker_io_job_cb(int fd, void *user_data)
        bundle *b = NULL;
        int clifd;
        struct ucred cr;
-       int ret;
 
        pkt = aul_sock_recv_pkt(fd, &clifd, &cr);
        if (!pkt) {
@@ -352,16 +366,6 @@ static bool __worker_io_job_cb(int fd, void *user_data)
                if (pkt->opt & AUL_SOCK_NOREPLY) {
                        close(clifd);
                        clifd = -1;
-               } else {
-                       ret = aul_sock_send_result(clifd, 0);
-                       if (ret < 0) {
-                               _E("Failed to send result. cmd(%s:%d)",
-                                       aul_cmd_convert_to_string(pkt->cmd),
-                                       pkt->cmd);
-                               free(pkt);
-                               return true;
-                       }
-                       clifd = -1;
                }
        }