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 {
89 ms_connection_t *connection;
90 ms_module_t *module[MUSE_MODULE_MAX];
92 ms_security_t *security;
94 ms_watchdog_t *watchdog;
98 char instance_pid_info[MUSE_MSG_LEN_MAX];
101 typedef struct ms_cmd_dispatch_info {
102 muse_module_command_e cmd;
103 muse_external_storage_info_t storage;
104 } ms_cmd_dispatcher_info_t;
106 void ms_setup_syslog(void);
107 void ms_fork(int *notify_fd);
108 pid_t ms_daemonize(int *notify_fd);
109 void ms_daemonize_complete(int notify_fd);
110 void ms_gst_init(char **cmd);
111 void ms_gst_preload_plugin(void);
112 int ms_pidfile_create(const char *path, pid_t pid);
113 void ms_init(char **argv);
114 muse_server_h ms_get_instance(void);
115 gboolean ms_check_module_idx(int idx);
116 ms_module_t *ms_get_module_instance(int idx);
118 void ms_check_cpu_memory(void);
121 void ms_cmd_dispatch(muse_module_h m, muse_module_command_e cmd);
122 void ms_terminate(int signo);
123 int ms_get_pid(muse_module_h m);
124 void ms_log_process_info(int pid);
125 void ms_log_user_group_info(void);
126 gboolean ms_is_log_enabled(void);
127 gboolean ms_init_bufmgr(void);
128 void ms_deinit_bufmgr(void);
129 void ms_cmd_dispatch_foreach_func(gpointer data, gpointer user_data);
130 void ms_set_state(ms_state_e state);
131 gboolean ms_is_server_ready(void);
132 gboolean ms_create_ready_file(void);
133 void ms_remove_ready_file(void);
134 const char *ms_get_command_string(int cmd);
135 gboolean ms_module_idx_is_valid(muse_module_h m);
140 #endif /*__MUSE_SERVER_PRIVATE_H__*/