void *muse_core_msg_object_new(char *str, int *parse_len, muse_core_msg_parse_err_e *err);
bool muse_core_msg_object_get_value(const char *key, void *jobj, muse_core_msg_type_e m_type, void *data);
void muse_core_msg_object_free(void *msg_obj);
-
+void muse_core_change_time_format(int val, char *time_buf);
void muse_core_dump_fd_state(int fd);
-
void muse_core_create_fd_table(void);
void muse_core_remove_all_fd_table(void);
void muse_core_destroy_fd_table(void);
#define LOG_TAG "MUSED_CORE"
#define STR_TIME_FORMAT "%m-%d %H:%M:%S"
+#define MUSE_MIN_SEC_VALUE 60
+#define MUSE_HOUR_MIN_VALUE 60
+#define MUSE_DAY_HOUR_VALUE 24
#define MUSE_WATCHDOG_CHECK_PERIOD 10
#define MUSE_WATCHDOG_CHECK_COUNT 3
return true;
}
+void muse_core_change_time_format(int val, char *time_buf)
+{
+ int sec, min, hour, day;
+
+ muse_return_if_fail(time_buf);
+
+ min = val / MUSE_MIN_SEC_VALUE;
+ hour = min / MUSE_HOUR_MIN_VALUE;
+ day = hour / MUSE_DAY_HOUR_VALUE;
+
+ sec = val % MUSE_MIN_SEC_VALUE;
+ min = min % MUSE_HOUR_MIN_VALUE;
+ hour = hour % MUSE_DAY_HOUR_VALUE;
+
+ snprintf(time_buf, MUSE_MSG_TIME_LEN, "%dd %dh %dm %ds", day, hour, min, sec);
+}
+
void muse_core_dump_fd_state(int fd)
{
+ int sec = 0;
+ char time_buf[MUSE_MSG_LEN];
+
g_mutex_lock(&fd_state_lock);
- LOGI("[%d] %s", fd, (char *)g_hash_table_lookup(fd_state_table, GINT_TO_POINTER(fd)));
+ sec = GPOINTER_TO_INT(g_hash_table_lookup(fd_state_table, GINT_TO_POINTER(fd)));
+ muse_core_change_time_format(sec, time_buf);
+ LOGI("[%d] %s", fd, time_buf);
g_mutex_unlock(&fd_state_lock);
}
void muse_core_update_fd_state(int fd)
{
- char atime[MUSE_MSG_TIME_LEN] = {'\0',};
+ struct timespec tv;
g_mutex_lock(&fd_state_lock);
if (!fd_state_table)
- fd_state_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
+ fd_state_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
- muse_core_get_cur_time(NULL, atime);
- g_hash_table_insert(fd_state_table, GINT_TO_POINTER(fd), g_strdup(atime));
+ muse_core_get_cur_time(&tv, NULL);
+ g_hash_table_insert(fd_state_table, GINT_TO_POINTER(fd), GINT_TO_POINTER((int)tv.tv_sec));
g_mutex_unlock(&fd_state_lock);
}
goto out;
}
- fd_state_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
+ fd_state_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
if (!fd_state_table)
LOGE("fail to create new fd state table");
out:
if (fp) {
while (fgets(buf, MUSE_MSG_LEN_MAX, fp)) {
- LOGW("%s", buf);
+ LOGI("%s", buf);
cpu += atoi(g_strstrip(buf));
}
intptr_t module_addr = 0;
GQueue *instance_queue = NULL;
ms_connection_t *connection = NULL;
+ char time_buf[MUSE_MSG_LEN];
muse_return_val_if_fail(channel == MUSE_CHANNEL_MSG || channel == MUSE_CHANNEL_DATA, FALSE);
}
muse_core_get_cur_time(&muse_server->tv, NULL);
-
- LOGW("connected time %lu", muse_server->tv.tv_sec);
+ muse_core_change_time_format((int)muse_server->tv.tv_sec, time_buf);
+ LOGW("connected time (%s)", time_buf);
_ms_unlock_state();
uint32_t elapsed_time;
struct timespec tv;
static int period_idx = 1;
+ char time_buf[MUSE_MSG_LEN];
muse_return_if_fail(muse_server);
muse_return_if_fail(muse_server->state == MUSE_SERVER_STATE_READY);
instance_number = g_queue_get_length(connection->instance_q);
if (elapsed_time >= (uint32_t)(period * period_idx)) {
- LOGW("[#%d] %u sec [period %d] [last connected time %lu] total number of modules = %d ( %s)", period_idx,
- elapsed_time, period, muse_server->tv.tv_sec, instance_number, muse_server->instance_pid_info);
+ muse_core_change_time_format((int)muse_server->tv.tv_sec, time_buf);
+ LOGW("[#%d] %u sec [period %d] [last connected time %s] total number of modules = %d ( %s)", period_idx,
+ elapsed_time, period, time_buf, instance_number, muse_server->instance_pid_info);
period_idx++;
}
static gboolean _ms_idle_cb(gpointer user_data)
{
struct timespec tv;
+ char time_buf[MUSE_MSG_LEN];
if (!ms_create_ready_file())
LOGE("%s file creation is failed", MUSE_SERVER_READY);
muse_core_get_cur_time(&tv, NULL);
- LOGW("muse server is completed to ready %lu", tv.tv_sec);
+ muse_core_change_time_format((int)tv.tv_sec, time_buf);
+
+ LOGW("muse server is completed to ready (%s)", time_buf);
return G_SOURCE_REMOVE;
}