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 _muse_server {
77 GThread *diag_idle_state_thread;
78 GThread *diag_connection_event_thread;
80 ms_connection_t *connection;
81 ms_module_t *module[MUSE_MODULE_MAX];
83 ms_security_t *security;
85 ms_watchdog_t *watchdog;
89 char instance_pid_info[MUSE_MSG_LEN_MAX];
92 typedef struct ms_cmd_dispatch_info {
93 muse_module_command_e cmd;
94 muse_external_storage_info_t storage;
95 } ms_cmd_dispatcher_info_t;
97 void ms_setup_syslog(void);
98 void ms_fork(int *notify_fd);
99 pid_t ms_daemonize(int *notify_fd);
100 void ms_daemonize_complete(int notify_fd);
101 void ms_gst_init(char **cmd);
102 void ms_gst_preload_plugin(void);
103 int ms_pidfile_create(const char *path, pid_t pid);
104 void ms_init(char **argv);
105 muse_server_h ms_get_instance(void);
106 gboolean ms_check_module_idx(int idx);
107 ms_module_t *ms_get_module_instance(int idx);
109 void ms_check_cpu_memory(int pid);
111 int ms_open_lockfile(void);
113 void ms_cmd_dispatch(muse_module_h m, muse_module_command_e cmd);
114 void ms_respawn(int signo);
115 int ms_get_pid(muse_module_h m);
116 void ms_log_process_info(int pid);
117 void ms_log_user_group_info(void);
118 gboolean ms_is_log_enabled(void);
119 int ms_kill_thread(int signo);
120 gboolean ms_init_bufmgr(void);
121 void ms_deinit_bufmgr(void);
122 void ms_cmd_dispatch_foreach_func(gpointer data, gpointer user_data);
123 void ms_set_state(ms_state_e state);
124 gboolean ms_is_server_ready(void);
125 void ms_diag_thread_create(void);
126 void ms_diag_thread_destroy(void);
127 gboolean ms_create_ready_file(void);
128 void ms_remove_ready_file(void);
133 #endif /*__MUSE_SERVER_PRIVATE_H__*/