dlog
glib-2.0
json-c
- mm-common)
+ mm-common
+ capi-system-resource)
SET(pc_dependents
mm-common)
*/
#include "muse_client.h"
+#include "muse_core_boost.h"
#include "muse_core_internal.h"
#ifdef LOG_TAG
static int _mc_new(muse_channel_e channel);
static void _mc_table_new(void);
static gpointer _mc_get_fd_ptr(int sock_fd);
-
static int _muse_client_new(muse_channel_e channel);
+static void _muse_client_boosting_start(ms_boost_t *bst);
+static void _muse_client_boosting_stop(ms_boost_t *bst);
#ifdef MUSE_USE_CLIENT_SIGHANDLER
static gboolean _mc_table_remove_func(gpointer key, gpointer value, gpointer user_data)
return g_hash_table_lookup(mc_table, GINT_TO_POINTER(sock_fd));
}
+static void _muse_client_boosting_start(ms_boost_t *bst)
+{
+ bst->is_boosted = muse_boosting_start();
+ if (!bst->is_boosted)
+ return;
+
+ bst->is_inheritted = muse_boosting_set_cpu_inheritance();
+}
+
+static void _muse_client_boosting_stop(ms_boost_t *bst)
+{
+ if (bst->is_inheritted)
+ bst->is_inheritted = !muse_boosting_clear_cpu_inheritance();
+
+ if (bst->is_boosted)
+ bst->is_boosted = !muse_boosting_stop();
+}
+
static int _muse_client_new(muse_channel_e channel)
{
+ int fd = -1;
+ ms_boost_t bst = { 0 };
+
if (!muse_server_is_ready()) {
LOGE("muse server is not ready");
return MM_ERROR_UNKNOWN;
if (channel == MUSE_CHANNEL_MSG)
_mc_table_new();
- return _mc_new(channel);
+ _muse_client_boosting_start(&bst);
+
+ fd = _mc_new(channel);
+
+ _muse_client_boosting_stop(&bst);
+
+ return fd;
}
int muse_client_new(void)
--- /dev/null
+/*
+ * muse-core
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * 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 __MUSE_CORE_BOOST_H__
+#define __MUSE_CORE_BOOST_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <cpu-boosting.h>
+
+typedef struct ms_boost {
+ gboolean is_boosted;
+ gboolean is_inheritted;
+ gboolean is_inheritance_registered;
+} ms_boost_t;
+
+gboolean muse_boosting_start(void);
+gboolean muse_boosting_stop(void);
+gboolean muse_boosting_set_cpu_inheritance(void);
+gboolean muse_boosting_clear_cpu_inheritance(void);
+gboolean muse_boosting_register_cpu_inheritance(void);
+gboolean muse_boosting_unregister_cpu_inheritance(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*__MUSE_CORE_BOOST_H__*/
#include <iniparser.h>
#include <time.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MUSED_CORE"
+
#define CONFFILE SYSCONFDIR"/multimedia/mused.conf"
#define MUSE_HOST "muse:hosts"
#define INI_PARSER_COMMA ","
#include <json.h>
#include <sys/mman.h>
-#undef LOG_TAG
-#define LOG_TAG "MUSED_CORE"
-
#define STR_TIME_FORMAT "%m-%d %H:%M:%S"
#define MUSE_MIN_SEC_VALUE 60
#define MUSE_HOUR_MIN_VALUE 60
--- /dev/null
+/*
+ * muse-core
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * 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 <sys/types.h>
+
+#include "muse_core_boost.h"
+#include "muse_core_internal.h"
+
+#define RESOURCE_CPU_DEST_NAME "muse-server"
+#define RESOURCE_TIMEOUT_MS 1000
+
+#ifndef RESOURCE_ERROR_NONE
+#define RESOURCE_ERROR_NONE 0
+#endif
+
+gboolean muse_boosting_start(void)
+{
+ pid_t source_tid = getpid();
+ resource_pid_t res_pid = {
+ .pid = 0,
+ .tid = &source_tid,
+ .tid_count = 1
+ };
+
+ int ret = resource_set_cpu_boosting(res_pid, CPU_BOOSTING_LEVEL_STRONG, (cpu_boosting_flag_e)0, -1);
+ if (ret != RESOURCE_ERROR_NONE) {
+ LOGE("resource_set_cpu_boosting() is failed. error 0x%x", ret);
+ return FALSE;
+ }
+
+ LOGI("resource_set_cpu_boosting success");
+
+ return TRUE;
+}
+
+gboolean muse_boosting_stop(void)
+{
+ pid_t pid = getpid();
+ resource_pid_t res_pid = {
+ .pid = 0,
+ .tid = &pid,
+ .tid_count = 1
+ };
+
+ int ret = resource_clear_cpu_boosting(res_pid);
+ if (ret != RESOURCE_ERROR_NONE) {
+ LOGE("resource_clear_cpu_boosting() is failed, error 0x%x", ret);
+ return FALSE;
+ }
+
+ LOGI("resource_clear_cpu_boosting success");
+
+ return TRUE;
+}
+
+// for Client(IPC Sender)
+gboolean muse_boosting_set_cpu_inheritance(void)
+{
+ pid_t pid = getpid();
+
+ int ret = resource_set_cpu_inheritance(pid, RESOURCE_CPU_DEST_NAME, RESOURCE_TIMEOUT_MS);
+ if (ret != RESOURCE_ERROR_NONE) {
+ LOGE("resource_set_cpu_inheritance() failed, error 0x%x", ret);
+ return FALSE;
+ }
+
+ LOGI("resource_set_cpu_inheritance success");
+
+ return TRUE;
+}
+
+gboolean muse_boosting_clear_cpu_inheritance(void)
+{
+ pid_t pid = getpid();
+
+ int ret = resource_clear_cpu_inheritance(pid, RESOURCE_CPU_DEST_NAME);
+ if (ret != RESOURCE_ERROR_NONE) {
+ LOGE("resource_clear_cpu_inheritance() failed, error 0x%x", ret);
+ return FALSE;
+ }
+
+ LOGI("resource_clear_cpu_inheritance() success");
+
+ return TRUE;
+}
+
+// for SERVER(IPC Receiver)
+gboolean muse_boosting_register_cpu_inheritance(void)
+{
+ resource_pid_t res_pid = { 0 };
+ res_pid.pid = getpid();
+
+ int ret = resource_register_cpu_inheritance_destination(RESOURCE_CPU_DEST_NAME, res_pid);
+ if (ret != RESOURCE_ERROR_NONE) {
+ LOGE("resource_register_cpu_inheritance_destination() failed, error 0x%x", ret);
+ return FALSE;
+ }
+
+ LOGI("resource_register_cpu_inheritance_destination() success");
+
+ return TRUE;
+}
+
+gboolean muse_boosting_unregister_cpu_inheritance(void)
+{
+ int ret = resource_unregister_cpu_inheritance_destination(RESOURCE_CPU_DEST_NAME);
+ if (ret != RESOURCE_ERROR_NONE) {
+ LOGE("resource_unregister_cpu_inheritance_destination() failed, error 0x%x", ret);
+ return FALSE;
+ }
+
+ LOGI("resource_unregister_cpu_inheritance_destination() success");
+
+ return TRUE;
+}
+
Name: mused
Summary: A multimedia daemon
-Version: 0.3.176
+Version: 0.3.177
Release: 0
Group: System/Libraries
License: Apache-2.0
BuildRequires: pkgconfig(libtbm)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(mm-common)
+BuildRequires: pkgconfig(capi-system-resource)
%if "%{tizen_profile_name}" == "tv"
BuildRequires: pkgconfig(libresourced)
BuildRequires: pkgconfig(lwipc)
BuildRequires: pkgconfig(ttrace)
-BuildRequires: pkgconfig(capi-system-resource)
%else
BuildRequires: pkgconfig(storage)
BuildRequires: pkgconfig(mm-resource-manager)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMUSE_USE_EXTERNAL_STORAGE_STATE_CHANGE")
ENDIF(${MUSE_STORAGE_ENABLE})
-IF(${MUSE_BOOST_ENABLE})
-SET(dependents ${dependents} " capi-system-resource")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMUSE_USE_BOOST")
-ENDIF(${MUSE_BOOST_ENABLE})
-
INCLUDE(FindPkgConfig)
pkg_check_modules(${MUSE_SERVER} REQUIRED ${dependents})
FOREACH(flag ${${MUSE_SERVER}_CFLAGS})
#ifndef __MUSE_SERVER_PRIVATE_H__
#define __MUSE_SERVER_PRIVATE_H__
+#include "muse_core_boost.h"
#include "muse_server.h"
#include "muse_server_config.h"
#include "muse_server_connection.h"
extern "C" {
#endif
+#ifdef LOG_TAG
#undef LOG_TAG
+#endif
#define LOG_TAG "MUSED_SERVER"
#define MSG_KEY_PID "pid"
#define MS_TIMEOUT_SEC 1
GAsyncQueue *msg_aq;
} ms_diag_t;
-typedef struct ms_boost {
- gboolean is_boosted;
- gboolean (*start_func)(void);
- gboolean (*stop_func)(void);
-} ms_boost_t;
-
typedef struct _muse_server {
int msg_fd;
int data_fd;
#include <malloc.h>
#include <tzplatform_config.h>
-#ifdef MUSE_USE_BOOST
-#include <cpu-boosting.h>
-#endif
-
#if !GLIB_CHECK_VERSION(2, 58, 0)
#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f))
#endif
static void _ms_launch_foreground(void);
static void _ms_daemonize(void);
-#ifdef MUSE_USE_BOOST
-gboolean _ms_boosting_start(void)
-{
- pid_t current_pid = getpid();
- resource_pid_t res_pid = {
- .pid = 0,
- .tid = ¤t_pid,
- .tid_count = 1,
- };
-
- // flags, timeout parameter is not working on VD
- int ret = resource_set_cpu_boosting(res_pid, CPU_BOOSTING_LEVEL_STRONG, (cpu_boosting_flag_e)0, -1);
- if (ret != 0) {
- LOGE("resource_set_cpu_boosting() is failed. error %d", ret);
- return FALSE;
- }
-
- LOGI("Leave");
-
- return TRUE;
-}
-
-gboolean _ms_boosting_stop(void)
-{
- pid_t current_pid = getpid();
- resource_pid_t res_pid = {
- .pid = 0,
- .tid = ¤t_pid,
- .tid_count = 1,
- };
-
- int ret = resource_clear_cpu_boosting(res_pid);
- if (ret != 0) {
- LOGE("resource_clear_cpu_boosting() is failed. error: %d", ret);
- return FALSE;
- }
-
- LOGI("Leave");
-
- return TRUE;
-}
-#endif
-
-void _ms_boosting_init(void)
-{
- muse_server->boost.is_boosted = FALSE;
-
-#ifdef MUSE_USE_BOOST
- muse_server->boost.start_func = _ms_boosting_start;
- muse_server->boost.stop_func = _ms_boosting_stop;
-#endif
-}
-
#ifdef MUSE_USE_LWIPC
static void _ms_wait_event(void);
static gboolean _ms_connection_handler(GIOChannel *source, GIOCondition condition, gpointer data)
{
- int server_sockfd, client_sockfd, pid, idx, len;
+ int server_sockfd = -1;
+ int client_sockfd = -1;
+ int pid;
+ int idx;
+ int len;
socklen_t client_len;
struct sockaddr_un client_address;
muse_channel_e channel = GPOINTER_TO_INT(data);
if (!ms_is_server_ready()) {
LOGW("Now mused state is not ready...");
- _ms_unlock_state();
- ms_terminate(SIGABRT);
+ goto out;
}
server_sockfd = g_io_channel_unix_get_fd(source);
if (!muse_core_fd_is_valid(server_sockfd)) {
LOGE("Critical Error : server %d is invalid", server_sockfd);
- _ms_unlock_state();
- muse_core_dump_fd_state(server_sockfd);
- ms_terminate(SIGABRT);
+ goto out;
}
client_len = (socklen_t)sizeof(client_address);
client_sockfd = accept(server_sockfd, (struct sockaddr *)&client_address, &client_len);
if (!muse_core_fd_is_valid(client_sockfd)) {
LOGE("Critical Error : accept %d is invalid", client_sockfd);
- muse_core_dump_fd_state(client_sockfd);
- close(server_sockfd);
- _ms_unlock_state();
- ms_terminate(SIGABRT);
+ goto out;
}
LOGI("server : %d client [%s channel] : %d", server_sockfd, channel_name[channel], client_sockfd);
pid = _ms_get_pid(client_sockfd);
if (pid == -1) {
close(client_sockfd);
- _ms_unlock_state();
- return FALSE;
+ goto out;
}
-
if (channel == MUSE_CHANNEL_MSG) {
m = g_new0(muse_module_t, 1);
SECURE_LOGI("module [%p]", m);
return TRUE;
out:
- close(server_sockfd);
- close(client_sockfd);
+ if (muse_core_fd_is_valid(server_sockfd))
+ close(server_sockfd);
+ if (muse_core_fd_is_valid(client_sockfd))
+ close(client_sockfd);
if (m)
muse_core_connection_close(m->ch[MUSE_CHANNEL_MSG].sock_fd);
LOGE("FALSE");
+ ms_terminate(SIGABRT);
+
return FALSE;
}
muse_server = g_new0(muse_server_t, 1);
- _ms_boosting_init();
-
for (idx = 1; argv[idx] != NULL; idx++) {
if (strcmp(argv[idx], "-D") == 0) {
LOGI("enable daemonize");
else
_ms_launch_foreground();
- if (muse_server->boost.start_func)
- muse_server->boost.is_boosted = muse_server->boost.start_func();
+ muse_server->boost.is_boosted = muse_boosting_start();
#ifdef MUSE_VIP_REGISTERED
proc_stat_set_vip_process();
#endif
if (muse_server->boost.is_boosted)
- muse_server->boost.is_boosted = !muse_server->boost.stop_func();
+ muse_server->boost.is_boosted = !muse_boosting_stop();
+
+ muse_server->boost.is_inheritance_registered = muse_boosting_register_cpu_inheritance();
LOGW("Leave");
}
ms_set_state(MUSE_SERVER_STATE_IDLE);
+ if (muse_server->boost.is_inheritance_registered)
+ muse_server->boost.is_inheritance_registered = !muse_boosting_unregister_cpu_inheritance();
+
_ms_diag_deinit();
#ifdef MUSE_USE_WATCHDOG