class CPUInheritance {
public:
- CPUInheritance() {
- int ret = resource_set_cpu_inheritance(gettid(),
- const_cast<char*>(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<char*>(DEST_PROCESS), -1);
+ if (ret != 0)
+ _E("resource_set_cpu_inheritance() is failed. error(%d)", ret);
+ else
+ inherited_ = true;
+ }
}
~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;
};
parcel.WriteParcelable(packet);
auto raw = parcel.GetRaw();
- const auto& inherit = CPUInheritance();
int ret = client->Send(reinterpret_cast<void*>(&raw[0]), raw.size());
if (ret != 0 || opt & AUL_SOCK_NOREPLY) {
if (opt & AUL_SOCK_ASYNC)
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());
static_assert(std::is_trivial<PacketHeader>(),
"Header should be POD type");
- const auto& inherit = CPUInheritance();
*out_pkt = nullptr;
int ret = client->Receive(&header, sizeof(header));
if (ret < 0)
else
is_blocking = true;
- const auto& inherit = CPUInheritance();
retry:
int ret = recvmsg(fd, &msg, 0);
if (ret == 0) {