#include "include/aul_sock.h"
-#include <cpu-boosting.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include "aul/socket/client_socket.hh"
#include "aul/socket/packet.hh"
#include "aul/socket/server_socket.hh"
+#include "cpu_inheritance.hh"
using namespace aul;
constexpr const char PATH_AUL_SOCKET_TIMEOUT[] = "/run/aul/.socket_timeout";
constexpr const char PATH_AMD_SOCK[] = "/run/aul/daemons/.amd-sock";
int MAX_FDS = sysconf(_SC_OPEN_MAX);
-constexpr const char DEST_PROCESS[] = "amd";
// POD type
struct PacketHeader {
int opt;
};
-class CPUInheritance {
- public:
- 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() {
- if (inherited_) {
- int ret = resource_clear_cpu_inheritance(gettid(),
- const_cast<char*>(DEST_PROCESS));
- if (ret != 0)
- _E("resource_clear_cpu_inheritance() is failed. error(%d)", ret);
- }
- }
-
- 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;
-};
-
class SocketTimeout {
public:
SocketTimeout() = default;
client.Connect(endpoint);
aul_sock_set_sock_option(client.GetFd(), 1);
- const auto& inherit = CPUInheritance(pid, cmd);
+ const auto& inherit = internal::CPUInheritance(pid, cmd);
ret = SendAndReceive(&client, cmd, data, datalen, opt);
} catch (const Exception& e) {
_E("Exception occurs. error(%d)", e.GetErrorCode());
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "cpu_inheritance.hh"
+
+#include <cpu-boosting.h>
+
+#include "include/aul_cmd.h"
+#include "aul_util.h"
+
+namespace aul {
+namespace internal {
+namespace {
+
+constexpr const char DEST_PROCESS[] = "amd";
+
+} // namespace
+
+CPUInheritance::CPUInheritance(pid_t 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::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::~CPUInheritance() {
+ if (inherited_) {
+ int ret = resource_clear_cpu_inheritance(gettid(),
+ const_cast<char*>(DEST_PROCESS));
+ if (ret != 0)
+ _E("resource_clear_cpu_inheritance() is failed. error(%d)", ret);
+ }
+}
+
+bool CPUInheritance::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_SYNC:
+ case RPC_PORT_PREPARE_STUB:
+ return true;
+ default:
+ return false;
+ }
+}
+
+} // namespace internal
+} // namespace aul
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CPU_INHERITANCE_HH_
+#define CPU_INHERITANCE_HH_
+
+#include <sys/types.h>
+
+namespace aul {
+namespace internal {
+
+class CPUInheritance {
+ public:
+ CPUInheritance(pid_t pid, int cmd);
+ CPUInheritance();
+ ~CPUInheritance();
+
+ private:
+ static bool IsLaunchRequest(int cmd);
+
+ private:
+ bool inherited_ = false;
+};
+
+} // namespace internal
+} // namespace aul
+
+#endif // CPU_INHERITANCE_HH_
#include "aul_svc.h"
#include "aul_svc_priv_key.h"
#include "aul_util.h"
+#include "cpu_inheritance.hh"
#include "launch.h"
using namespace aul::internal;
public:
ErrorInfo(std::string seq_num, tizen_base::Bundle b, int cmd,
ErrCb error_cb, void* user_data)
- : seq_num_(std::move(seq_num)), b_(std::move(b)), cmd_(cmd),
- error_cb_(std::move(error_cb)), user_data_(user_data) {
+ : seq_num_(std::move(seq_num)),
+ b_(std::move(b)), cmd_(cmd),
+ error_cb_(std::move(error_cb)),
+ user_data_(user_data) {
}
ErrorInfo(const ErrorInfo&) = delete;
int cmd_;
ErrCb error_cb_;
void* user_data_;
+ CPUInheritance inheritance_;
};
std::string __gen_seq_num() {