4 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: YoungHun Kim <yh8004.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MUSE_SERVER_PRIVATE_H__
23 #define __MUSE_SERVER_PRIVATE_H__
25 #include "muse_server.h"
26 #include "muse_server_config.h"
27 #include "muse_server_connection.h"
28 #include "muse_server_log.h"
29 #include "muse_server_module.h"
30 #include "muse_server_signal.h"
31 #include "muse_server_security.h"
32 #include "muse_server_system.h"
33 #include "muse_server_watchdog.h"
34 #include "muse_server_tool.h"
35 #include <systemd/sd-daemon.h>
40 #ifdef MUSE_TTRACE_LOG
49 #define LOG_TAG "MUSED_SERVER"
50 #define MSG_KEY_PID "pid"
51 #define MS_TIMEOUT_SEC 1
52 #define MS_TIMEOUT_MSEC MS_TIMEOUT_SEC * 1000
53 #define MS_RECV_TRY_COUNT_MAX 3
54 #define MSG_DONE "DONE"
56 gboolean ms_ipc_create_msg_dispatch_worker(muse_module_h m);
57 gboolean ms_ipc_create_data_dispatch_worker(muse_module_h m);
60 MUSE_SERVER_STATE_IDLE,
61 MUSE_SERVER_STATE_READY
64 typedef struct _muse_server *muse_server_h;
66 typedef struct ms_diag_msg {
71 typedef struct ms_diag {
72 GThread *idle_state_thread;
73 GThread *conn_event_thread;
77 typedef struct _muse_server {
88 ms_connection_t *connection;
89 ms_module_t *module[MUSE_MODULE_MAX];
91 ms_security_t *security;
93 ms_watchdog_t *watchdog;
97 char instance_pid_info[MUSE_MSG_LEN_MAX];
100 typedef struct ms_cmd_dispatch_info {
101 muse_module_command_e cmd;
102 muse_external_storage_info_t storage;
103 } ms_cmd_dispatcher_info_t;
105 void ms_setup_syslog(void);
106 void ms_fork(int *notify_fd);
107 pid_t ms_daemonize(int *notify_fd);
108 void ms_daemonize_complete(int notify_fd);
109 void ms_gst_init(char **cmd);
110 void ms_gst_preload_plugin(void);
111 int ms_pidfile_create(const char *path, pid_t pid);
112 void ms_init(char **argv);
113 muse_server_h ms_get_instance(void);
114 gboolean ms_check_module_idx(int idx);
115 ms_module_t *ms_get_module_instance(int idx);
117 void ms_check_cpu_memory(void);
120 void ms_cmd_dispatch(muse_module_h m, muse_module_command_e cmd);
121 void ms_terminate(int signo);
122 int ms_get_pid(muse_module_h m);
123 void ms_log_process_info(int pid);
124 void ms_log_user_group_info(void);
125 gboolean ms_is_log_enabled(void);
126 gboolean ms_init_bufmgr(void);
127 void ms_deinit_bufmgr(void);
128 void ms_cmd_dispatch_foreach_func(gpointer data, gpointer user_data);
129 void ms_set_state(ms_state_e state);
130 gboolean ms_is_server_ready(void);
131 gboolean ms_create_ready_file(void);
132 void ms_remove_ready_file(void);
133 const char *ms_get_command_string(int cmd);
134 gboolean ms_module_idx_is_valid(muse_module_h m);
139 #endif /*__MUSE_SERVER_PRIVATE_H__*/