static void _muse_core_log_pid_info(pid_t pid);
static void _muse_core_log_cmdline(pid_t pid);
static void _muse_core_log_process_info(pid_t pid);
-static void _muse_core_log_api_name(gpointer ptr);
+static void _muse_core_log_api_name(int pid, gpointer ptr);
static void _muse_core_log_api_info(void);
static void _muse_core_log_binary_info(void);
static int _muse_core_log_fd_set_block(int fd);
static void _muse_core_log_write_buffer(const void *buf, size_t len);
static void _muse_core_log_attributes(const char *msg, ...);
static void _muse_core_log_monitor(char *msg);
-static void _muse_core_log_cache_latest_msg(char *msg);
+static void _muse_core_log_cache_latest_msg(int pid, char *msg);
static void _muse_core_log_fatal(char *msg);
static void _muse_core_log_set_msg(char *msg);
static char *_muse_core_log_get_msg(void);
static void _muse_core_log_free(void);
static void _muse_core_log_init_instance(void(*log)(char *), void(*log_attr)(const char *, ...), void(*fatal)(char *),
void(*set_msg)(char *), char *(*get_msg)(void), void(*flush_msg)(void),
- void(*log_api_name)(gpointer), void(*save_debug_info)(pid_t), void(*free)(void));
+ void(*log_api_name)(int, gpointer), void(*save_debug_info)(pid_t), void(*free)(void));
static gboolean _muse_core_log_pid_is_valid(pid_t pid)
{
static void _muse_core_log_latest_msgs(void)
{
- int idx, start_idx;
+ int idx = 0;
g_return_if_fail(muse_core_is_log_enabled());
g_return_if_fail(g_muse_core_log);
g_mutex_lock(&g_muse_core_log->log_lock);
if (muse_core_ipc_fd_is_valid(g_muse_core_log->log_fd)) {
- start_idx = (g_muse_core_log->currnt_index + 1) % MUSE_LOG_MSG_NUM;
-
- for (idx = start_idx; idx < MUSE_LOG_MSG_NUM; idx++) {
+ LOGE("----------LATEST MUSE COMMAND----------");
+ for (idx = g_muse_core_log->currnt_index; idx < MUSE_LOG_MSG_NUM; idx++) {
+ LOGE("%s", g_muse_core_log->latest_msgs[idx]);
if (write(g_muse_core_log->log_fd, g_muse_core_log->latest_msgs[idx], strlen(g_muse_core_log->latest_msgs[idx])) == WRITE_FAIL)
LOGE("fail to write sequentially the latest message by first step");
else if (write(g_muse_core_log->log_fd, "\n", 1) == WRITE_FAIL)
LOGE("fail to write new line character");
}
-
- for (idx = 0; idx < start_idx; idx++) {
+ for (idx = 0; idx < g_muse_core_log->currnt_index; idx++) {
+ LOGE("%s", g_muse_core_log->latest_msgs[idx]);
if (write(g_muse_core_log->log_fd, g_muse_core_log->latest_msgs[idx], strlen(g_muse_core_log->latest_msgs[idx])) == WRITE_FAIL)
LOGE("fail to write sequentially the latest message by second step");
else if (write(g_muse_core_log->log_fd, "\n", 1) == WRITE_FAIL)
LOGE("fail to write new line character");
}
+ LOGE("---------------------------------------");
}
g_mutex_unlock(&g_muse_core_log->log_lock);
}
}
-static void _muse_core_log_api_name(gpointer ptr)
+static void _muse_core_log_api_name(int pid, gpointer ptr)
{
Dl_info info;
memset(&info, 0, sizeof(info));
if (dladdr((const void *) ptr, &info) && info.dli_sname)
- _muse_core_log_cache_latest_msg((char *)info.dli_sname);
+ _muse_core_log_cache_latest_msg(pid, (char *)info.dli_sname);
else
LOGE("fail to log api name");
}
g_mutex_unlock(&g_muse_core_log->log_lock);
}
-static void _muse_core_log_cache_latest_msg(char *msg)
+static void _muse_core_log_cache_latest_msg(int pid, char *msg)
{
g_return_if_fail(msg);
g_return_if_fail(g_muse_core_log);
gettimeofday(&tv, NULL);
strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", localtime_r(&(tv.tv_sec), &newtime));
- snprintf(g_muse_core_log->latest_msgs[g_muse_core_log->currnt_index], MUSE_LOG_MSG_LEN, "%s.%03ld %s ", time_buf, tv.tv_usec / 1000, msg);
+ snprintf(g_muse_core_log->latest_msgs[g_muse_core_log->currnt_index], MUSE_LOG_MSG_LEN, "[P%5d] %s.%03ld %s ", pid, time_buf, tv.tv_usec / 1000, msg);
g_muse_core_log->currnt_index = (g_muse_core_log->currnt_index + 1) % MUSE_LOG_MSG_NUM;
static void _muse_core_log_init_instance(void(*log)(char *), void(*log_attr)(const char *, ...), void(*fatal)(char *),
void(*set_msg)(char *), char *(*get_msg)(void), void(*flush_msg)(void),
- void(*log_api_name)(gpointer), void(*save_debug_info)(pid_t), void(*free)(void))
+ void(*log_api_name)(int, gpointer), void(*save_debug_info)(pid_t), void(*free)(void))
{
g_return_if_fail(log);
g_return_if_fail(fatal);
#include "muse_core_module.h"
#include "muse_core_private.h"
-#define API_SET_URI 5
-#define API_SET_PROGRESSIVE_DOWNLOAD_PATH 49
-#define API_SET_SUBTITLE_PATH 55
-
static muse_core_module_t *g_muse_core_module = NULL;
static GModule *_muse_core_module_load(int api_module);
static gboolean _muse_core_module_dispatch_callback(gpointer data)
{
+ muse_module_h module = (muse_module_h)data;
+
LOGE("Restart muse server");
+
+ if (module) {
+ LOGE("module[%p], pid[%d], api_module[%d], cmd[%d]",
+ module, module->pid, module->api_module, module->last_cmd);
+ } else {
+ LOGE("invalid pointer for module");
+ }
+
muse_core_respawn(SIGABRT);
return FALSE;
static gboolean _muse_core_module_enable_dispatch_callback(int cmd, muse_module_h module)
{
- if (module->api_module == MUSE_PLAYER) {
- if (cmd == API_SET_URI || cmd == API_SET_PROGRESSIVE_DOWNLOAD_PATH || cmd == API_SET_SUBTITLE_PATH)
- return FALSE;
- else
- return TRUE;
- } else {
+ if (module->api_module == MUSE_CAMERA || module->api_module == MUSE_RECORDER) {
if (cmd == API_CREATE)
return FALSE;
- else
- return TRUE;
}
+
+ return TRUE;
}
static void _muse_core_module_dispatch(int cmd, muse_module_h module)
{
guint id = 0;
- gboolean rm_success;
- gboolean enable_dispatch_callback;
+ gboolean rm_success = FALSE;
+ gboolean enable_dispatch_callback = FALSE;
muse_module_dispatchfunc *dispatcher = NULL;
if (module->ch[MUSE_CHANNEL_MSG].dll_handle) {
g_module_symbol(module->ch[MUSE_CHANNEL_MSG].dll_handle, DISPATCHER, (gpointer *)&dispatcher);
+ module->last_cmd = cmd;
+
if (dispatcher && dispatcher[cmd]) {
enable_dispatch_callback = _muse_core_module_enable_dispatch_callback(cmd, module);
+
if (enable_dispatch_callback) {
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);
}
+
if (muse_core_is_log_enabled()) {
_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]);
+ muse_core_log_get_instance()->log_api_name(module->pid, (gpointer) dispatcher[cmd]);
}
+
dispatcher[cmd](module);
+
if (enable_dispatch_callback) {
rm_success = g_source_remove(id);
if (!rm_success)