From: Hwankyu Jhun Date: Fri, 15 Jul 2022 07:01:26 +0000 (+0900) Subject: Fix cpu inheritance feature X-Git-Tag: accepted/tizen/unified/20220720.064044~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F277944%2F2;p=platform%2Fcore%2Fappfw%2Faul-1.git Fix cpu inheritance feature The AUL calls the resource_set_cpu_inheritance() function if the callee is AMD and the request is a launch request. Change-Id: Ida09e991f23ca10486d2539fe955755aea31650d Signed-off-by: Hwankyu Jhun --- diff --git a/src/aul_sock.cc b/src/aul_sock.cc index 3e996df..1050ca4 100644 --- a/src/aul_sock.cc +++ b/src/aul_sock.cc @@ -59,13 +59,15 @@ struct PacketHeader { class CPUInheritance { public: - CPUInheritance() { - int ret = resource_set_cpu_inheritance(gettid(), - const_cast(DEST_PROCESS), -1); - if (ret != 0) - _E("resource_set_cpu_inheritance() is failed. error(%d)", ret); - else - inherited_ = true; + CPUInheritance(int pid, int cmd) { + if (pid == -2 && IsLaunchRequest(cmd)) { + int ret = resource_set_cpu_inheritance(gettid(), + const_cast(DEST_PROCESS), -1); + if (ret != 0) + _E("resource_set_cpu_inheritance() is failed. error(%d)", ret); + else + inherited_ = true; + } } ~CPUInheritance() { @@ -78,6 +80,24 @@ class CPUInheritance { } private: + static bool IsLaunchRequest(int cmd) { + switch (cmd) { + case APP_START: + case APP_OPEN: + case APP_RESUME: + case APP_START_RES: + case APP_START_ASYNC: + case APP_SEND_LAUNCH_REQUEST: + case APP_SEND_LAUNCH_REQUEST_SYNC: + case RPC_PORT_PREPARE_STUB: + case APP_SEND_RESUME_REQUEST: + return true; + default: + return false; + } + } + + private: bool inherited_ = false; }; @@ -207,7 +227,6 @@ int SendAndReceive(ClientSocket* client, int cmd, unsigned char* data, parcel.WriteParcelable(packet); auto raw = parcel.GetRaw(); - const auto& inherit = CPUInheritance(); int ret = client->Send(reinterpret_cast(&raw[0]), raw.size()); if (ret != 0 || opt & AUL_SOCK_NOREPLY) { if (opt & AUL_SOCK_ASYNC) @@ -242,6 +261,7 @@ int SendAndReceive(int pid, uid_t uid, int cmd, unsigned char* data, client.Connect(endpoint); aul_sock_set_sock_option(client.GetFd(), 1); + const auto& inherit = CPUInheritance(pid, cmd); ret = SendAndReceive(&client, cmd, data, datalen, opt); } catch (const Exception& e) { _E("Exception occurs. error(%d)", e.GetErrorCode()); @@ -258,7 +278,6 @@ int ReceiveAppPacket(ClientSocket* client, app_pkt_t** out_pkt) { static_assert(std::is_trivial(), "Header should be POD type"); - const auto& inherit = CPUInheritance(); *out_pkt = nullptr; int ret = client->Receive(&header, sizeof(header)); if (ret < 0) @@ -328,7 +347,6 @@ int ReceiveMessage(int fd, struct iovec* vec, int vec_max_size, int* vec_size, else is_blocking = true; - const auto& inherit = CPUInheritance(); retry: int ret = recvmsg(fd, &msg, 0); if (ret == 0) {