int muse_core_run(void);
void muse_core_cmd_dispatch(muse_module_h module, muse_module_command_e cmd);
+void muse_core_set_dispatch_timeout(muse_module_h module, int disp_api, int timeout);
+int muse_core_get_dispatch_timeout(muse_module_h module, int disp_api);
void muse_core_connection_close(int sock_fd);
int muse_core_client_new(void);
int muse_core_client_new_data_ch(void);
bool muse_core_msg_object_get_value(void *msg_obj, const char *key, int m_type, void *data);
void muse_core_msg_object_free(void *msg_obj);
void muse_core_respawn(int signo);
+int muse_core_get_api_module(char *module_name, int *api_module);
#ifdef __cplusplus
}
#include "muse_core_module.h"
#define CONFFILE SYSCONFDIR"/multimedia/mused.conf"
-#define HOST_MAX_COUNT 1024
-#define MUSE_MAX_PARAM_NUM 10
#define MUSEHOST "muse:hosts"
#define MUSELOG "muse:logfile"
+#define MUSELOCK "muse:lockfile"
+#define MUSEREADY "muse:muse_server_ready"
+#define MUSEMINTIMEOUT "muse:min_timeout"
+#define MUSEMAXTIMEOUT "muse:max_timeout"
#define MUSEGST "muse:gstparam"
#define COLON ":"
#define COMMA ","
#define PATH "path"
#define PRELOADED "preloaded"
+#define TIMEOUT "timeout"
typedef struct host_info
{
char *path;
char *preloaded;
+ int timeout;
} host_info_t;
typedef struct muse_core_config
{
char *hosts;
- char *host[MUSE_MODULE_MAX];
- int type;
+ char *host[MUSE_MAX_MODULE_NUM];
+ int host_cnt;
char *logfile;
+ char *lockfile;
+ char *muse_server_ready;
+ int min_timeout;
+ int max_timeout;
+
char *gst_param_str[MUSE_MAX_PARAM_NUM];
int gst_param_cnt;
- host_info_t *host_infos[HOST_MAX_COUNT];
+ host_info_t *host_infos[MUSE_MAX_MODULE_NUM];
dictionary *muse_dict;
void (*free)(void);
char* (*get_path)(int);
int (*get_host_cnt)(void);
} muse_core_config_t;
-/*muse_core_config_init must be called before muse_core_config_get_instance*/
muse_core_config_t *muse_core_config_get_instance(void);
void muse_core_config_init(void);
#undef LOG_TAG
#define LOG_TAG "TIZEN_N_MUSED"
-#define LOGFILE "/var/log/mused/muse-server"
-#define LOCKFILE "/tmp/.muse_core.lock"
-#define SOCKFILE0 "/tmp/.muse_core_socket"
-#define SOCKFILE1 "/tmp/.muse_core_data_socket"
-#define MUSE_SERVER_READY "/tmp/.muse_server_ready"
-#define MUSE_DEFAULT_PIDFILE "/tmp/.muse-server.pid"
#define MUSE_DATA_ROOT_PATH TZ_SYS_DATA_PATH"/mused/"
-
-#ifdef MUSE_USE_LOG
-#define MUSE_TIMEOUT_SEC 30
-#define MUSE_TIMEOUT_MSEC 30000
-#else
-#define MUSE_TIMEOUT_SEC 90
-#define MUSE_TIMEOUT_MSEC 90000
-#endif
+#define MUSE_DEFAULT_PIDFILE "/tmp/.muse-server.pid"
+#define MUSE_SOCK_FILE0 "/tmp/.muse_core_socket"
+#define MUSE_SOCK_FILE1 "/tmp/.muse_core_data_socket"
#define READ 0x02
#define PERSIST 0x10
-#define MUSE_MAX_ERROR_MSG_LEN 256
-#define MUSE_MAX_PARAM_STRLEN 256
-#define MUSE_TUNABLE_CALLER_DEPTH 32
+
+#define MUSE_ERR -1
+#define MUSE_MAX_PARAM_NUM 10
+
+/* message */
#define MUSE_MSG_LEN 32
+#define MUSE_MAX_MSG_LEN 256
+
+/* module */
+#define MUSE_MAX_MODULE_NUM 10
+
+/* dispatcher */
+#define MUSE_MAX_DISPATCHER_NUM 256
-#define SOCK_ERR -1
#define DISPATCHER "dispatcher"
#define DISPATCHER_PTR "dispatcher_pointer"
#define CMD_DISPATCHER "cmd_dispatcher"
#define END_DELIM '}'
+#define END_DELIM_STR " }"
#define MUSE_FREE(src) \
do { \
MUSE_PLAYER,
MUSE_CAMERA,
MUSE_RECORDER,
- MUSE_SOUND,
MUSE_DRM,
MUSE_MODULE_MAX
} muse_core_api_module_e;
GModule* (*get_dllsymbol_value) (int);
void (*set_value) (int, const char *, gpointer);
int (*get_value) (int, const char *, gpointer *);
+ void (*set_timeout) (int, int, int);
+ int (*get_timeout) (int, int);
void (*free) (void);
- GMutex module_lock[MUSE_MODULE_MAX];
- gboolean module_loaded[MUSE_MODULE_MAX];
- GModule *module[MUSE_MODULE_MAX];
- GHashTable *table[MUSE_MODULE_MAX];
+ GMutex module_lock[MUSE_MAX_MODULE_NUM];
+ gboolean module_loaded[MUSE_MAX_MODULE_NUM];
+ GModule *module[MUSE_MAX_MODULE_NUM];
+ GHashTable *table[MUSE_MAX_MODULE_NUM];
int api_module;
+ int disp_timeout[MUSE_MAX_MODULE_NUM][MUSE_MAX_DISPATCHER_NUM];
} muse_core_module_t;
muse_core_module_t *muse_core_module_get_instance(void);
#define MUSE_LWIPC_WAIT_TIME 1000
#endif
-#define MUSE_LOG_SLEEP_TIMER 10
-#define END_DELIM_STR " }"
-#define MUSE_WATCHDOG_TIMEOUT_SEC 30
-
static GMainLoop *g_loop;
static GThread *g_thread;
-static const char *UDS_files[MUSE_CHANNEL_MAX] = {SOCKFILE0, SOCKFILE1};
+static const char *UDS_files[MUSE_CHANNEL_MAX] = {MUSE_SOCK_FILE0, MUSE_SOCK_FILE1};
static gboolean (*job_functions[MUSE_CHANNEL_MAX])
(muse_core_workqueue_job_t *job) = {
static int _muse_core_set_nonblocking(int fd, bool value)
{
int flags = fcntl(fd, F_GETFL, NULL);
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
if (flags >= 0) {
flags = value ? (flags | O_NONBLOCK) : (flags & ~O_NONBLOCK);
if (fcntl(fd, F_SETFL, flags) == -1) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("fcntl (%d, F_SETFL, %d) %s", fd, flags, err_msg);
return MM_ERROR_FILE_INTERNAL;
} else {
int ret = -1;
/* First, check whether the existing file is locked. */
- fd = open(LOCKFILE, O_RDONLY);
+ fd = open(muse_core_config_get_instance()->lockfile, O_RDONLY);
if (fd == -1 && errno != ENOENT) {
/* Cannot open file, but it's not because the file doesn't exist. */
char msg[1024];
- snprintf(msg, sizeof(msg), "datserver: Cannot open lock file %s", LOCKFILE);
+ snprintf(msg, sizeof(msg), "datserver: Cannot open lock file %s", muse_core_config_get_instance()->lockfile);
LOGE("open failed: %s ", msg);
return ret;
} else if (fd != -1) {
}
/* Lock file does not exist, or is not locked. Create a new lockfile and lock it. */
- fd = open(LOCKFILE, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ fd = open(muse_core_config_get_instance()->lockfile, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd == -1) {
LOGE("dataserver: Cannot create lock file");
return ret;
}
if (flock(fd, LOCK_EX | LOCK_NB) != 0) {
- LOGE("Can't lock the lock file \"%s\". " "Is another instance running?", LOCKFILE);
+ LOGE("Can't lock the lock file \"%s\". " "Is another instance running?", muse_core_config_get_instance()->lockfile);
close(fd);
return ret;
}
close(server->data_fd);
for (i = 0; i < MUSE_CHANNEL_MAX; i++)
remove(UDS_files[i]);
- remove(LOCKFILE);
+ remove(muse_core_config_get_instance()->lockfile);
remove(MUSE_DEFAULT_PIDFILE);
MUSE_FREE(server);
muse_core_workqueue_get_instance()->shutdown();
int fd;
struct sockaddr_un addr_un;
socklen_t address_len;
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
g_return_val_if_fail(channel < MUSE_CHANNEL_MAX, MM_ERROR_INVALID_ARGUMENT);
/* Create Socket */
fd = socket(AF_UNIX, SOCK_STREAM, 0); /* Unix Domain Socket */
if (fd < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("socket failed sock: %s", err_msg);
- return SOCK_ERR;
+ return MUSE_ERR;
} else {
LOGD("muse server fd : %d", fd);
}
/* Bind to filename */
if (bind(fd, (struct sockaddr *)&addr_un, sizeof(addr_un)) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("socket bind failed : %s", err_msg);
if (errno == EADDRINUSE)
unlink(addr_un.sun_path);
close(fd);
- return SOCK_ERR;
+ return MUSE_ERR;
}
/* Setup listen queue */
- if (listen(fd, 5) == SOCK_ERR) {
+ if (listen(fd, 5) == MUSE_ERR) {
LOGE("listen failed");
close(fd);
- return SOCK_ERR;
+ return MUSE_ERR;
}
if (_muse_core_set_nonblocking(fd, false) < 0) /* blocking */
socklen_t client_len;
struct sockaddr_un client_address;
muse_core_channel_e channel = (muse_core_channel_e)data;
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
muse_module_h module = NULL;
muse_core_workqueue_job_t *job = NULL;
client_len = sizeof(client_address);
client_sockfd = accept(server_sockfd, (struct sockaddr *)&client_address, &client_len);
- if (client_sockfd == SOCK_ERR) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ if (client_sockfd == MUSE_ERR) {
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[Critical Error] accept failure : %s", err_msg);
muse_core_respawn(SIGTERM);
return FALSE;
static int _muse_core_client_new(muse_core_channel_e channel)
{
struct sockaddr_un address;
- int len, ret = SOCK_ERR;
+ int len, ret = MUSE_ERR;
int sockfd;
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
LOGI("Enter");
g_return_val_if_fail(channel < MUSE_CHANNEL_MAX, MM_ERROR_INVALID_ARGUMENT);
/*Create socket*/
if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[socket failure] sock: %s", err_msg);
return ret;
}
LOGI("sockfd: %d", sockfd);
if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("unable to set on ctrls socket fd %d: %s", sockfd, err_msg);
close(sockfd);
return ret;
LOGE("Error - fd (%d) set blocking", sockfd);
if ((ret = connect(sockfd, (struct sockaddr *)&address, len)) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[Critical Error] connect failure : %s", err_msg);
close(sockfd);
return ret;
#ifdef MUSE_USE_LWIPC
_muse_core_wait_event();
- if (LwipcEventDone(MUSE_SERVER_READY) < 0)
+ if (LwipcEventDone(muse_core_config_get_instance()->muse_server_ready) < 0)
LOGE("Fail to send server ready done event");
#else
- if ((ready_fd = creat(MUSE_SERVER_READY, 0644)) != -1) {
- LOGD("MUSE_SERVER_READY(%s) file was created", MUSE_SERVER_READY);
+ if ((ready_fd = creat(muse_core_config_get_instance()->muse_server_ready, 0644)) != -1) {
+ LOGD("MUSE_SERVER_READY(%s) file was created", muse_core_config_get_instance()->muse_server_ready);
close(ready_fd);
} else {
- LOGE("Fail to create MUSE_SERVER_READY(%s)", MUSE_SERVER_READY);
+ LOGE("Fail to create MUSE_SERVER_READY(%s)", muse_core_config_get_instance()->muse_server_ready);
}
#endif
}
}
+void muse_core_set_dispatch_timeout(muse_module_h module, int disp_api, int timeout)
+{
+ g_return_if_fail(module);
+
+ muse_core_module_get_instance()->set_timeout(module->api_module, disp_api, timeout);
+}
+
+int muse_core_get_dispatch_timeout(muse_module_h module, int disp_api)
+{
+ g_return_val_if_fail(module, MUSE_ERR);
+
+ return muse_core_module_get_instance()->get_timeout(module->api_module, disp_api);
+}
+
int muse_core_client_new(void)
{
return _muse_core_client_new(MUSE_CHANNEL_MSG);
void muse_core_connection_close(int sock_fd)
{
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
g_return_if_fail(muse_core_ipc_fd_is_valid(sock_fd));
- if (shutdown(sock_fd, SHUT_RDWR) == SOCK_ERR) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ if (shutdown(sock_fd, SHUT_RDWR) == MUSE_ERR) {
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%d] failed to shutdown %s", sock_fd, err_msg);
}
- if (close(sock_fd) == SOCK_ERR) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ if (close(sock_fd) == MUSE_ERR) {
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%d] failed to close %s", sock_fd, err_msg);
}
void muse_core_log_process_info(int pid)
{
FILE *fp;
- char cmd[MUSE_MAX_PARAM_STRLEN];
- char buf[MUSE_MAX_PARAM_STRLEN];
+ char cmd[MUSE_MAX_MSG_LEN];
+ char buf[MUSE_MAX_MSG_LEN];
snprintf(cmd, sizeof(cmd), "ps -Lo pcpu,pmem,tid,comm -p %d", (int)pid);
fp = popen(cmd, "r");
if (fp) {
- while (fgets(buf, MUSE_MAX_PARAM_STRLEN, fp))
+ while (fgets(buf, MUSE_MAX_MSG_LEN, fp))
LOGD("%s", buf);
if (pclose(fp) == -1)
LOGE("send %d process signal %d", (int)pid, signo);
kill(pid, signo);
}
+
+int muse_core_get_api_module(char *module_name, int *api_module)
+{
+ int idx;
+ g_return_val_if_fail(module_name, MM_ERROR_INVALID_ARGUMENT);
+ g_return_val_if_fail(api_module, MM_ERROR_INVALID_ARGUMENT);
+
+ for (idx = 0; idx < muse_core_config_get_instance()->host_cnt; idx++) {
+ if (strncmp(module_name, muse_core_config_get_instance()->host[idx], strlen(muse_core_config_get_instance()->host[idx])) == 0) {
+ *api_module = idx;
+ break;
+ }
+ }
+
+ g_return_val_if_fail(idx < muse_core_config_get_instance()->host_cnt, MM_ERROR_NOT_IMPLEMENTED);
+
+ return MM_ERROR_NONE;
+}
char *host;
char *str;
int idx;
+ int host_cnt;
char *ptr = NULL;
g_return_val_if_fail(g_muse_core_conf, PARSE_ERROR);
return PARSE_ERROR;
}
+ str = iniparser_getstring(g_muse_core_conf->muse_dict, MUSELOCK, NULL);
+ if (!str) {
+ LOGE("Error - iniparser_getstring (%s)", MUSELOCK);
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+ g_muse_core_conf->lockfile = strdup(str);
+ if (!g_muse_core_conf->lockfile) {
+ LOGE("Error - lockfile allocation");
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+ str = iniparser_getstring(g_muse_core_conf->muse_dict, MUSEREADY, NULL);
+ if (!str) {
+ LOGE("Error - iniparser_getstring (%s)", MUSEREADY);
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+ g_muse_core_conf->muse_server_ready = strdup(str);
+ if (!g_muse_core_conf->muse_server_ready) {
+ LOGE("Error - muse_server_ready allocation");
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+ str = iniparser_getstring(g_muse_core_conf->muse_dict, MUSEMINTIMEOUT, NULL);
+ if (!str) {
+ LOGE("Error - iniparser_getstring (%s)", MUSEMINTIMEOUT);
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+ g_muse_core_conf->min_timeout = atoi(strdup(str));
+ if (!g_muse_core_conf->min_timeout) {
+ LOGE("Error - Get minimum timeout");
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+ str = iniparser_getstring(g_muse_core_conf->muse_dict, MUSEMAXTIMEOUT, NULL);
+ if (!str) {
+ LOGE("Error - iniparser_getstring (%s)",MUSEMAXTIMEOUT);
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+ g_muse_core_conf->max_timeout = atoi(strdup(str));
+ if (!g_muse_core_conf->max_timeout) {
+ LOGE("Error - Get maximum timeout");
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
g_muse_core_conf->gst_param_cnt = 0;
- for (idx = 0 ; idx < MUSE_MAX_PARAM_NUM; idx++) {
- char gst_param_value[MUSE_MAX_PARAM_STRLEN];
- memset(gst_param_value, 0, MUSE_MAX_PARAM_STRLEN);
+ for (idx = 0 ; idx < muse_core_config_get_instance()->host_cnt; idx++) {
+ char gst_param_value[MUSE_MAX_MSG_LEN];
+ memset(gst_param_value, 0, MUSE_MAX_MSG_LEN);
snprintf(gst_param_value, strlen(MUSEGST) + 2, "%s%d", MUSEGST, idx + 1);
str = iniparser_getstring(g_muse_core_conf->muse_dict, gst_param_value, NULL);
LOGD("gstparam%d: %s", (g_muse_core_conf->gst_param_cnt)++, g_muse_core_conf->gst_param_str[idx]);
}
- g_muse_core_conf->type = 0;
+ g_muse_core_conf->host_cnt = 0;
host = strtok_r(g_muse_core_conf->hosts, COMMA, &ptr);
while (host) {
+ host_cnt = g_muse_core_conf->host_cnt;
g_strstrip(host);
- g_muse_core_conf->host[g_muse_core_conf->type] = strdup(host);
- LOGD("host: %s", g_muse_core_conf->host[g_muse_core_conf->type]);
- char *host_name = (char *) malloc(HOST_MAX_COUNT);
+ g_muse_core_conf->host[host_cnt] = strdup(host);
+ LOGD("host: %s", g_muse_core_conf->host[host_cnt]);
+ char *host_name = (char *) malloc(MUSE_MAX_MSG_LEN);
if (!host_name) {
LOGE("Error - null host_name");
_muse_core_config_free();
strncpy(host_name, host, strlen(host) + 1);
strncat(host_name, COLON, strlen(COLON));
strncat(host_name, PATH, strlen(PATH));
- g_strstrip(host_name); /*Removes leading and trailing whitespace from a string*/
+ g_strstrip(host_name);
- g_muse_core_conf->host_infos[g_muse_core_conf->type] = (host_info_t *) malloc(sizeof(host_info_t));
- if (!g_muse_core_conf->host_infos[g_muse_core_conf->type]) {
+ g_muse_core_conf->host_infos[host_cnt] = (host_info_t *) malloc(sizeof(host_info_t));
+ if (!g_muse_core_conf->host_infos[host_cnt]) {
LOGE("Error - null type");
_muse_core_config_free();
MUSE_FREE(host_name);
return PARSE_ERROR;
}
- g_muse_core_conf->host_infos[g_muse_core_conf->type]->path = strdup(iniparser_getstring(g_muse_core_conf->muse_dict, host_name, NULL));
- if (!g_muse_core_conf->host_infos[g_muse_core_conf->type]->path) {
+ g_muse_core_conf->host_infos[host_cnt]->path =
+ strdup(iniparser_getstring(g_muse_core_conf->muse_dict, host_name, NULL));
+ if (!g_muse_core_conf->host_infos[host_cnt]->path) {
LOGE("Error - null path");
_muse_core_config_free();
MUSE_FREE(host_name);
return PARSE_ERROR;
}
- LOGD("[%d] %s", g_muse_core_conf->type, g_muse_core_conf->host_infos[g_muse_core_conf->type]->path);
+ LOGD("[%d] %s", host_cnt, g_muse_core_conf->host_infos[host_cnt]->path);
- /* path */
+ /* preloaded */
strncpy(host_name, host, strlen(host) + 1);
strncat(host_name, COLON, strlen(COLON));
strncat(host_name, PRELOADED, strlen(PRELOADED));
- g_strstrip(host_name); /*Removes leading and trailing whitespace from a string*/
+ g_strstrip(host_name);
- g_muse_core_conf->host_infos[g_muse_core_conf->type]->preloaded= strdup(iniparser_getstring(g_muse_core_conf->muse_dict, host_name, NULL));
- if (!g_muse_core_conf->host_infos[g_muse_core_conf->type]->preloaded) {
+ g_muse_core_conf->host_infos[host_cnt]->preloaded =
+ strdup(iniparser_getstring(g_muse_core_conf->muse_dict, host_name, NULL));
+ if (!g_muse_core_conf->host_infos[host_cnt]->preloaded) {
LOGE("Error - null preloaded");
_muse_core_config_free();
MUSE_FREE(host_name);
return PARSE_ERROR;
}
+ /* timeout */
+ strncpy(host_name, host, strlen(host) + 1);
+ strncat(host_name, COLON, strlen(COLON));
+ strncat(host_name, TIMEOUT, strlen(TIMEOUT));
+ g_strstrip(host_name);
+
+ g_muse_core_conf->host_infos[host_cnt]->timeout =
+ atoi(strdup(iniparser_getstring(g_muse_core_conf->muse_dict, host_name, NULL)));
+ if (g_muse_core_conf->host_infos[host_cnt]->timeout < g_muse_core_conf->min_timeout ||
+ g_muse_core_conf->host_infos[host_cnt]->timeout > g_muse_core_conf->max_timeout) {
+ LOGE("Error - set timeout value [%d] ( %d ~ %d s )",
+ g_muse_core_conf->host_infos[host_cnt]->timeout,
+ g_muse_core_conf->min_timeout, g_muse_core_conf->max_timeout);
+ _muse_core_config_free();
+ return PARSE_ERROR;
+ }
+
+
host = strtok_r(NULL, COMMA, &ptr);
- g_muse_core_conf->type++;
+ g_muse_core_conf->host_cnt++;
MUSE_FREE(host_name);
}
iniparser_freedict(g_muse_core_conf->muse_dict);
host = strtok_r(g_muse_core_conf->hosts, COMMA, &ptr);
- g_muse_core_conf->type = 0;
+ g_muse_core_conf->host_cnt = 0;
while (host) {
LOGD("host: %s", host);
- MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->type]->path);
- MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->type]->preloaded);
- MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->type]);
+ MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]->path);
+ MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]->preloaded);
+ MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]);
host = strtok_r(NULL, COMMA, &ptr);
- g_muse_core_conf->type++;
+ g_muse_core_conf->host_cnt++;
}
+
MUSE_FREE(g_muse_core_conf->hosts);
- for (i = 0; i <= g_muse_core_conf->type; i++)
+ for (i = 0; i <= g_muse_core_conf->host_cnt; i++)
MUSE_FREE(g_muse_core_conf->host[i]);
MUSE_FREE(g_muse_core_conf->logfile);
+ MUSE_FREE(g_muse_core_conf->lockfile);
+ MUSE_FREE(g_muse_core_conf->muse_server_ready);
+
for (i = 0; i <= g_muse_core_conf->gst_param_cnt; i++)
MUSE_FREE(g_muse_core_conf->gst_param_str[i]);
g_muse_core_conf = calloc(1, sizeof(*g_muse_core_conf));
g_return_if_fail(g_muse_core_conf);
- g_muse_core_conf->hosts = NULL;
- g_muse_core_conf->type = 0;
- g_muse_core_conf->logfile = NULL;
- g_muse_core_conf->muse_dict = NULL;
+
g_muse_core_conf->free = free;
g_muse_core_conf->get_path = get_path;
g_muse_core_conf->get_preloaded = get_preloaded;
static int _muse_core_config_get_host_cnt(void)
{
g_return_val_if_fail(g_muse_core_conf, 0);
- return g_muse_core_conf->type;
+ return g_muse_core_conf->host_cnt;
}
static int _muse_core_config_get_gst_param_cnt(void)
muse_module_h module = NULL;
gboolean value = TRUE;
void *jobj = NULL;
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
g_return_val_if_fail(data, NULL);
- int tbm_fd[MUSE_NUM_FD] = { SOCK_ERR, };
+ int tbm_fd[MUSE_NUM_FD] = { MUSE_ERR, };
module = (muse_module_h)data;
g_return_val_if_fail(module, NULL);
memset(module->recvMsg, 0x00, sizeof(module->recvMsg));
len = muse_core_ipc_recv_fd_msg(module->ch[MUSE_CHANNEL_MSG].fd, module->recvMsg, tbm_fd);
if (len <= 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%s] [%d] recv : %s (%d)",
muse_core_config_get_instance()->get_host(module->api_module), module->ch[MUSE_CHANNEL_MSG].fd, err_msg, errno);
muse_core_cmd_dispatch(module, MUSE_MODULE_COMMAND_SHUTDOWN);
module->is_create_api_called = true;
module->ch[MUSE_CHANNEL_MSG].dll_handle = muse_core_module_get_instance()->load(api_module);
#ifndef MUSE_USE_LWIPC
- if (access(MUSE_SERVER_READY, F_OK) == 0)
+ if (access(muse_core_config_get_instance()->muse_server_ready, F_OK) == 0)
#endif
muse_core_cmd_dispatch(module, MUSE_MODULE_COMMAND_CREATE_SERVER_ACK);
module->ch[MUSE_CHANNEL_DATA].queue = g_queue_new();
void *jobj = NULL;
intptr_t module_addr = 0;
muse_recv_data_t *qdata = NULL;
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
g_return_val_if_fail(fd > 0, NULL);
LOGD("Enter");
LOGI("buff %p, recv_len %d, cur_len %d, alloc_size %d", recv_buf, recv_len, cur_len, alloc_size);
if (recv_len <= 0) {
if (recv_len != 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%d] recv : %s (%d)", fd, err_msg, errno);
}
break;
{
int idx;
for (idx = 0; idx < MUSE_NUM_FD; idx++) {
- if (fds[idx] == SOCK_ERR)
+ if (fds[idx] == MUSE_ERR)
break;
}
return idx;
struct msghdr msg;
struct iovec iov;
char data[CMSG_SPACE(sizeof(int) * MUSE_NUM_FD)];
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
int *fdptr;
int fd_cnt = 0;
}
}
- if ((ret = sendmsg(sock_fd, &msg, 0)) == SOCK_ERR) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ if ((ret = sendmsg(sock_fd, &msg, 0)) == MUSE_ERR) {
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("fail to send msg (%s) %d", err_msg, sock_fd);
}
struct iovec iov;
size_t completed_msg_len = 0;
char data[CMSG_SPACE(sizeof(int) * MUSE_NUM_FD)];
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
g_return_val_if_fail(buf, MM_ERROR_INVALID_ARGUMENT);
msg.msg_control = data;
msg.msg_controllen = sizeof(data);
- if ((ret = recvmsg(sock_fd, &msg, 0)) == SOCK_ERR) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ if ((ret = recvmsg(sock_fd, &msg, 0)) == MUSE_ERR) {
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("fail to receive msg (%s)", err_msg);
return ret;
}
int muse_core_ipc_set_timeout(int sock_fd, int timeout_sec)
{
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
struct timeval tv;
LOGD("Enter");
tv.tv_sec = timeout_sec;
tv.tv_usec = 0L;
- if (setsockopt(sock_fd, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, (socklen_t)sizeof(tv)) == SOCK_ERR) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ if (setsockopt(sock_fd, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, (socklen_t)sizeof(tv)) == MUSE_ERR) {
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%d] Failed to set socket send timeout option (%s) %d", sock_fd, err_msg, errno);
return MM_ERROR_UNKNOWN;
}
- if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, (socklen_t)sizeof(tv)) == SOCK_ERR) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, (socklen_t)sizeof(tv)) == MUSE_ERR) {
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%d] Failed to set socket recv timeout option (%s) %d", sock_fd, err_msg, errno);
return MM_ERROR_UNKNOWN;
}
int muse_core_ipc_push_data(int sock_fd, const char *data, int size, uint64_t data_id)
{
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
muse_recv_data_head_t header;
int sended_len = 0;
sock_fd, header.marker, header.size, header.id);
if ((sended_len = send(sock_fd, &header, sizeof(muse_recv_data_head_t), 0)) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%d] fail to send msg (%s) %d", sock_fd, err_msg, errno);
}
if ((sended_len += send(sock_fd, data, size, 0)) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("[%d] fail to send msg (%s) %d", sock_fd, err_msg, errno);
}
while (g_queue_is_empty(ch->queue)) {
end_time = g_get_monotonic_time() + WAIT_MSEC * G_TIME_SPAN_MILLISECOND;
if (!g_cond_wait_until(&ch->cond, &ch->mutex, end_time) || wait_try++ > MAX_RETRIES) {
- LOGW("[%d] No signal during %lldms", wait_try, end_time);
+ LOGW("[%d] No signal during %lldus", wait_try, end_time);
g_mutex_unlock (&ch->mutex);
return NULL;
}
gboolean muse_core_ipc_fd_is_valid(int fd)
{
- return (fcntl(fd, F_GETFL) != SOCK_ERR || errno != EBADF) && (fd > STDERR_FILENO);
+ return (fcntl(fd, F_GETFL) != MUSE_ERR || errno != EBADF) && (fd > STDERR_FILENO);
}
int muse_core_ipc_get_bufmgr(tbm_bufmgr *bufmgr)
static gboolean _muse_core_log_pid_is_valid(pid_t pid)
{
- char client_buf[MUSE_MAX_ERROR_MSG_LEN];
+ char client_buf[MUSE_MAX_MSG_LEN];
snprintf(client_buf, sizeof(client_buf), "/proc/%d", (int)pid);
static void _muse_core_log_pid_info(pid_t pid)
{
- char client_buf[MUSE_MAX_ERROR_MSG_LEN];
+ char client_buf[MUSE_MAX_MSG_LEN];
g_return_if_fail(g_muse_core_log);
g_return_if_fail(muse_core_ipc_fd_is_valid(g_muse_core_log->log_fd));
static void _muse_core_log_cmdline(pid_t pid)
{
- char client_buf[MUSE_MAX_ERROR_MSG_LEN];
+ char client_buf[MUSE_MAX_MSG_LEN];
FILE *fp;
g_return_if_fail(g_muse_core_log);
snprintf(client_buf, sizeof(client_buf), "/proc/%d/cmdline", (int)pid);
fp = fopen(client_buf, "r");
if (fp) {
- size_t size = fread(client_buf, sizeof(char), MUSE_MAX_ERROR_MSG_LEN, fp);
+ size_t size = fread(client_buf, sizeof(char), MUSE_MAX_MSG_LEN, fp);
client_buf[size] = '\0';
if (write(g_muse_core_log->log_fd, client_buf, strlen(client_buf)) == WRITE_FAIL)
static void _muse_core_log_process_info(pid_t pid)
{
- char client_buf[MUSE_MAX_ERROR_MSG_LEN];
+ char client_buf[MUSE_MAX_MSG_LEN];
FILE *fp;
g_return_if_fail(g_muse_core_log);
else if (write(g_muse_core_log->log_fd, "\n", 1) == WRITE_FAIL)
LOGE("fail to write process command");
- while (fgets(client_buf, MUSE_MAX_ERROR_MSG_LEN, fp)) {
+ while (fgets(client_buf, MUSE_MAX_MSG_LEN, fp)) {
if (write(g_muse_core_log->log_fd, client_buf, strlen(client_buf)) == WRITE_FAIL)
LOGE("fail to write command info to logfile");
}
static void _muse_core_log_api_info(void)
{
Dl_info info;
- char client_buf[MUSE_MAX_ERROR_MSG_LEN];
+ char client_buf[MUSE_MAX_MSG_LEN];
gpointer ptr;
int i;
g_return_if_fail(g_muse_core_log);
g_return_if_fail(muse_core_ipc_fd_is_valid(g_muse_core_log->log_fd));
- for (i = 0; i < MUSE_MODULE_MAX; i++) {
+ for (i = 0; i < muse_core_config_get_instance()->host_cnt; i++) {
muse_core_module_get_instance()->get_value(i, DISPATCHER_PTR, &ptr);
memset(&info, 0, sizeof(info));
if (dladdr((const void *) ptr, &info) && info.dli_sname) {
static void _muse_core_log_binary_info(void)
{
- char client_buf[MUSE_MAX_ERROR_MSG_LEN];
+ char client_buf[MUSE_MAX_MSG_LEN];
FILE *fp;
char *label;
char *value;
fp = fopen("/etc/tizen-release", "r");
g_return_if_fail(fp);
- while (fgets(client_buf, MUSE_MAX_ERROR_MSG_LEN, fp)) {
+ while (fgets(client_buf, MUSE_MAX_MSG_LEN, fp)) {
label = strtok_r(client_buf, delimiter, &ptr);
if (label) {
- if (strcmp(label, BUILD_ID) == 0) {
+ if (strncmp(label, BUILD_ID, strlen(BUILD_ID)) == 0) {
value = strtok_r(NULL, delimiter, &ptr);
if (value) {
if (write(g_muse_core_log->log_fd, value, strlen(value)) != WRITE_FAIL)
{
int selected_index, index;
struct stat st;
- char file[MAX_FILE_NUM][MUSE_TUNABLE_CALLER_DEPTH];
+ char file[MAX_FILE_NUM][MUSE_MSG_LEN];
g_return_if_fail(g_muse_core_log);
for (index = 0; index < MAX_FILE_NUM; index++)
- snprintf(file[index], strlen(LOGFILE) + 3, "%s.%d", LOGFILE, index);
+ snprintf(file[index], strlen(muse_core_config_get_instance()->logfile) + 3, "%s.%d", muse_core_config_get_instance()->logfile, index);
for (index = 0; index < MAX_FILE_NUM; index++) {
if (access(file[index], F_OK) == 0) { /* if 0, then there is file */
static void _muse_core_log_set_log_fd(void)
{
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
g_return_if_fail(g_muse_core_log);
_muse_core_log_create_fd();
g_return_if_fail(muse_core_ipc_fd_is_valid(g_muse_core_log->log_fd));
if (fcntl(g_muse_core_log->log_fd, F_SETFD, FD_CLOEXEC) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("unable to set CLO_EXEC on log fd %d: %s", g_muse_core_log->log_fd, err_msg);
}
g_muse_core_log = calloc(1, sizeof(*g_muse_core_log));
g_return_if_fail(g_muse_core_log);
- memset(g_muse_core_log->buf, 0, MUSE_MSG_MAX_LENGTH + 1);
- g_muse_core_log->size = 0;
- memset(g_muse_core_log->cache, 0, MUSE_MSG_MAX_LENGTH + 1);
+
g_muse_core_log->log = log;
g_muse_core_log->log_attr = log_attr;
g_muse_core_log->fatal = fatal;
g_muse_core_log->save_debug_info = save_debug_info;
g_muse_core_log->free = free;
g_mutex_init(&g_muse_core_log->log_lock);
- g_muse_core_log->currnt_index = 0;
}
static void
static gboolean _muse_core_module_get_dllsymbol_loaded_value(int api_module);
static void _muse_core_module_set_dllsymbol_value(int api_module, const char *keyname, gpointer value);
static int _muse_core_module_get_dllsymbol_value(int api_module, const char *keyname, gpointer *value);
+static void _muse_core_module_set_timeout(int api_module, int disp_api, int timeout);
+static int _muse_core_module_get_timeout(int api_module, int disp_api);
static void _muse_core_module_init_instance(GModule* (*load) (int), void (*dispatch) (int, muse_module_h), gboolean (*close) (muse_module_h),
void (*free) (void), GModule * (*get_dllsymbol_value) (int), void (*set_dllsymbol_loaded_value) (int, GModule *, gboolean), gboolean(*get_dllsymbol_loaded_value) (int),
- void (*set_value) (int, const char *, gpointer), int (*get_value) (int, const char *, gpointer *));
+ void (*set_value) (int, const char *, gpointer), int (*get_value) (int, const char *, gpointer *), void (*set_timeout) (int, int, int), int (*get_timeout) (int, int));
static GModule *_muse_core_module_load(int api_module)
g_module_symbol(module->ch[MUSE_CHANNEL_MSG].dll_handle, DISPATCHER, (gpointer *)&dispatcher);
if (dispatcher && dispatcher[cmd]) {
- id = g_timeout_add_seconds(MUSE_TIMEOUT_SEC, (GSourceFunc) _muse_core_module_dispatch_callback, (gpointer) module);
+ id = g_timeout_add_seconds((guint)g_muse_core_module->disp_timeout[module->api_module][module->disp_api],
+ (GSourceFunc) _muse_core_module_dispatch_callback, (gpointer) module);
#ifdef MUSE_USE_LOG
_muse_core_module_set_dllsymbol_value(module->api_module, DISPATCHER_PTR, (gpointer) dispatcher[cmd]);
muse_core_log_get_instance()->log_api_name((gpointer) dispatcher[cmd]);
static void _muse_core_module_set_dllsymbol_value(int api_module, const char *keyname, gpointer value)
{
+ gpointer orig_key;
+
g_return_if_fail(g_muse_core_module);
g_return_if_fail(keyname);
- gpointer orig_key;
-
g_mutex_lock(&g_muse_core_module->module_lock[api_module]);
/* Try looking up this key. */
}
}
+static void _muse_core_module_set_timeout(int api_module, int disp_api, int timeout)
+{
+ g_return_if_fail(g_muse_core_module);
+ g_return_if_fail(timeout >= muse_core_config_get_instance()->min_timeout &&
+ timeout <= muse_core_config_get_instance()->max_timeout);
+
+ g_mutex_lock(&g_muse_core_module->module_lock[api_module]);
+
+ g_muse_core_module->disp_timeout[api_module][disp_api] = timeout;
+
+ g_mutex_unlock(&g_muse_core_module->module_lock[api_module]);
+}
+
+static int _muse_core_module_get_timeout(int api_module, int disp_api)
+{
+ g_return_val_if_fail(g_muse_core_module, MUSE_ERR);
+
+ return g_muse_core_module->disp_timeout[api_module][disp_api];
+}
+
static gboolean _muse_core_module_free_key(gpointer key, gpointer value, gpointer user_data)
{
MUSE_G_FREE(key);
g_return_if_fail(g_muse_core_module);
- for (idx = 0; idx < MUSE_MODULE_MAX; idx++) {
+ for (idx = 0; idx < muse_core_config_get_instance()->host_cnt; idx++) {
g_mutex_clear(&g_muse_core_module->module_lock[idx]);
g_module_close(g_muse_core_module->module[idx]);
g_hash_table_foreach_remove(g_muse_core_module->table[idx], _muse_core_module_free_key, NULL);
static void _muse_core_module_init_instance(GModule* (*load) (int), void (*dispatch) (int, muse_module_h), gboolean (*close) (muse_module_h),
void (*free) (void), GModule * (*get_dllsymbol_value) (int), void (*set_dllsymbol_loaded_value) (int, GModule *, gboolean), gboolean(*get_dllsymbol_loaded_value) (int),
- void (*set_value) (int, const char *, gpointer), int (*get_value) (int, const char *, gpointer *))
+ void (*set_value) (int, const char *, gpointer), int (*get_value) (int, const char *, gpointer *), void (*set_timeout) (int, int, int), int (*get_timeout) (int, int))
{
+ int module_idx = 0;
+ int module_timeout = 0;
+ int disp_idx = 0;
+
g_return_if_fail(g_muse_core_module == NULL);
- int idx = 0;
g_muse_core_module = calloc(1, sizeof(*g_muse_core_module));
g_return_if_fail(g_muse_core_module);
g_muse_core_module->set_value = set_value;
g_muse_core_module->get_value = get_value;
- for (idx = 0; idx < MUSE_MODULE_MAX; idx++) {
- g_mutex_init(&g_muse_core_module->module_lock[idx]);
- g_muse_core_module->module_loaded[idx] = FALSE;
- g_muse_core_module->table[idx] = g_hash_table_new(g_str_hash, g_str_equal);
- g_return_if_fail(g_muse_core_module->table[idx]);
+ for (module_idx = 0; module_idx < muse_core_config_get_instance()->host_cnt; module_idx++) {
+ module_timeout = muse_core_config_get_instance()->host_infos[module_idx]->timeout;
+ g_mutex_init(&g_muse_core_module->module_lock[module_idx]);
+ g_muse_core_module->module_loaded[module_idx] = FALSE;
+ g_muse_core_module->table[module_idx] = g_hash_table_new(g_str_hash, g_str_equal);
+ g_return_if_fail(g_muse_core_module->table[module_idx]);
+ for (disp_idx = 0; disp_idx < MUSE_MAX_DISPATCHER_NUM; disp_idx++)
+ _muse_core_module_set_timeout(module_idx, disp_idx, module_timeout);
}
}
if (g_muse_core_module == NULL)
_muse_core_module_init_instance(_muse_core_module_load, _muse_core_module_dispatch, _muse_core_module_close, _muse_core_module_free,
_muse_core_module_get_dllsymbol, _muse_core_module_set_dllsymbol_loaded_value, _muse_core_module_get_dllsymbol_loaded_value,
- _muse_core_module_set_dllsymbol_value, _muse_core_module_get_dllsymbol_value);
+ _muse_core_module_set_dllsymbol_value, _muse_core_module_get_dllsymbol_value,
+ _muse_core_module_set_timeout, _muse_core_module_get_timeout);
LOGD("Leave");
}
g_muse_core_security = calloc(1, sizeof(*g_muse_core_security));
g_return_if_fail(g_muse_core_security);
- g_muse_core_security->p_cynara= NULL;
+
g_muse_core_security->new= new;
g_muse_core_security->free = free;
}
int fd;
struct flock lock;
char pid_buf[MUSE_MSG_LEN] = {'\0',};
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
fd = open(path, O_WRONLY | O_CREAT, (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH));
if (fd < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("Fail to open pidfile [%s] : %s", path, err_msg);
return MM_ERROR_FILE_NOT_FOUND;
}
if (fcntl(fd, F_SETLK, &lock) < 0) {
if (errno != EACCES && errno != EAGAIN) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("Fail to lock pidfile [%s] : %s", path, err_msg);
} else {
LOGE("process is already running");
}
if (ftruncate(fd, 0) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("Fail to truncate pidfile [%s] : %s", path, err_msg);
close(fd);
return MM_ERROR_FILE_INTERNAL;
snprintf(pid_buf, sizeof(pid_buf), "%u", pid);
if (write(fd, pid_buf, strlen(pid_buf)) != (int)strlen(pid_buf)) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("Fail to write pid to pidfile [%s] : %s", path, err_msg);
close(fd);
return MM_ERROR_FILE_WRITE;
int result;
pid_t pid;
int index;
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
#ifdef MUSE_TTRACE_LOG
trace_begin("MUSE:START");
/* daemonizing */
if ((pid = fork()) < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("Error: fork() failed: %s", err_msg);
exit(EXIT_SUCCESS);
} else if (pid != 0) {
trace_begin("MUSE:preloading module");
#endif
for (index = 0; index < muse_core_config_get_instance()->get_host_cnt(); index++) {
- if (0 == strcmp(muse_core_config_get_instance()->get_preloaded(index), "yes")) {
+ if (0 == strncmp(muse_core_config_get_instance()->get_preloaded(index), "yes", strlen("yes"))) {
muse_module_h module = NULL;
muse_module_cmd_dispatchfunc *cmd_dispatcher = NULL;
#include "muse_core_log.h"
#include "muse_core_internal.h"
+#include "muse_core_config.h"
struct sigaction muse_segv_old_action;
struct sigaction muse_abrt_old_action;
static void _muse_core_signal_backtrace(void *arg)
{
- void *trace[MUSE_TUNABLE_CALLER_DEPTH];
+ void *trace[MUSE_MSG_LEN];
int tracesize;
int i;
char **strings = NULL;
ucontext_t *uctxt = NULL;
- char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
+ char err_msg[MUSE_MAX_MSG_LEN] = {'\0',};
LOGE("----------BEGIN MUSE DYING MESSAGE----------");
- tracesize = backtrace(trace, MUSE_TUNABLE_CALLER_DEPTH);
+ tracesize = backtrace(trace, MUSE_MSG_LEN);
if (tracesize < 0) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("backtrace error: %s", err_msg);
}
#endif
strings = backtrace_symbols(trace, tracesize);
if (strings == NULL) {
- strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+ strerror_r(errno, err_msg, MUSE_MAX_MSG_LEN);
LOGE("backtrace_symbols error: %s", err_msg);
} else {
/* skip the first stack frame because it just points here. */
g_return_if_fail(arg);
#ifdef MUSE_USE_LWIPC
- if (LwipcResetEvent(MUSE_SERVER_READY) < 0)
+ if (LwipcResetEvent(muse_core_config_get_instance()->muse_server_ready) < 0)
LOGE("Fail to reset light weight IPC");
#else
- remove(MUSE_SERVER_READY);
+ remove(muse_core_config_get_instance()->muse_server_ready);
#endif
_muse_core_signal_backtrace(arg);