#include <sys/time.h>
#include <unistd.h>
#include <iniparser.h>
+#include <time.h>
#define CONFFILE SYSCONFDIR"/multimedia/mused.conf"
#define MUSE_HOST "muse:hosts"
bool muse_core_msg_recv_len(int fd, char *buf, int msg_len);
void muse_core_update_fd_state(int fd);
-void muse_core_get_cur_time(char *time_buf);
+void muse_core_get_cur_time(struct timespec *time, char *time_buf);
#ifdef __cplusplus
}
#include <sys/mman.h>
#undef LOG_TAG
-#define LOG_TAG "MUSED_CORE"
+#define LOG_TAG "MUSED_CORE"
+
+#define STR_TIME_FORMAT "%m-%d %H:%M:%S"
#define MUSE_WATCHDOG_CHECK_PERIOD 10
#define MUSE_WATCHDOG_CHECK_COUNT 3
if (!fd_state_table)
fd_state_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
- muse_core_get_cur_time(atime);
+ muse_core_get_cur_time(NULL, atime);
g_hash_table_insert(fd_state_table, GINT_TO_POINTER(fd), g_strdup(atime));
g_mutex_unlock(&fd_state_lock);
g_mutex_unlock(&fd_state_lock);
}
-void muse_core_get_cur_time(char *time_buf)
+void muse_core_get_cur_time(struct timespec *time, char *time_buf)
{
char cur_time[MUSE_MSG_LEN];
struct tm newtime;
- struct timeval tv;
+ struct timespec tv;
- muse_return_if_fail(time_buf);
+ muse_return_if_fail(clock_gettime(CLOCK_MONOTONIC, &tv) == 0);
- gettimeofday(&tv, NULL);
- strftime(cur_time, MUSE_MSG_LEN, "%m-%d %H:%M:%S", localtime_r(&(tv.tv_sec), &newtime));
+ if (time)
+ *time = tv;
- snprintf(time_buf, MUSE_MSG_TIME_LEN, "%s.%03ld", cur_time, tv.tv_usec / 1000);
+ if (time_buf) {
+ strftime(cur_time, MUSE_MSG_LEN, STR_TIME_FORMAT, localtime_r(&(tv.tv_sec), &newtime));
+ snprintf(time_buf, MUSE_MSG_TIME_LEN, "%s.%03ld", cur_time, tv.tv_nsec);
+ }
}
void muse_core_log_process_thread_info(int pid)
Name: mused
Summary: A multimedia daemon
-Version: 0.3.121
+Version: 0.3.122
Release: 0
Group: System/Libraries
License: Apache-2.0
ms_watchdog_t *watchdog;
ms_state_e state;
GMutex state_lock;
- struct timeval tv_s;
+ struct timespec tv;
char instance_pid_info[MUSE_MSG_LEN_MAX];
} muse_server_t;
muse_return_if_fail(muse_core_fd_is_valid(log->fd));
muse_return_if_fail(_ms_log_pid_is_valid(pid));
- muse_core_get_cur_time(time_buf);
+ muse_core_get_cur_time(NULL, time_buf);
snprintf(log_buf, MUSE_MSG_LEN_MAX, "[PID] %d %s", pid, time_buf);
ms_log_write(log_buf);
g_mutex_lock(&log->lock);
- muse_core_get_cur_time(time_buf);
+ muse_core_get_cur_time(NULL, time_buf);
snprintf(log->latest_msgs[log->cur_idx], MUSE_MSG_LEN_MAX, "[P%5d] %s %s", pid, time_buf, msg);
log->cur_idx = (log->cur_idx + 1) % MUSE_LOG_MSG_NUM;
ms_ipc_create_data_dispatch_worker(m);
}
- if (gettimeofday(&muse_server->tv_s, NULL) != 0) {
- LOGE("gettimeofday() failed");
- ms_terminate(SIGABRT);
- }
+ muse_core_get_cur_time(&muse_server->tv, NULL);
- LOGI("connected time %lu", muse_server->tv_s.tv_sec);
+ LOGW("connected time %lu", muse_server->tv.tv_sec);
_ms_unlock_state();
{
ms_connection_t *connection = NULL;
ms_config_t *conf = NULL;
- struct timeval tv_c, tv_r;
int instance_number, period;
uint32_t elapsed_time;
+ struct timespec tv;
static int period_idx = 1;
muse_return_if_fail(muse_server);
period = ms_config_get_log_period();
- if ((int)muse_server->tv_s.tv_sec == 0)
+ if (muse_server->tv.tv_sec == 0)
return;
- muse_return_if_fail(gettimeofday(&tv_c, NULL) == 0);
-
- timersub(&tv_c, &muse_server->tv_s, &tv_r);
+ muse_core_get_cur_time(&tv, NULL);
- elapsed_time = tv_r.tv_sec;
+ elapsed_time = tv.tv_sec - muse_server->tv.tv_sec;
ms_connection_lock(connection);
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_s.tv_sec, instance_number, muse_server->instance_pid_info);
+ elapsed_time, period, muse_server->tv.tv_sec, instance_number, muse_server->instance_pid_info);
period_idx++;
}
static gboolean _ms_idle_cb(gpointer user_data)
{
+ struct timespec tv;
+
if (!ms_create_ready_file())
LOGE("%s file creation is failed", MUSE_SERVER_READY);
_ms_diag_init();
+ muse_core_get_cur_time(&tv, NULL);
+
+ LOGW("muse server is completed to ready %lu", tv.tv_sec);
+
return G_SOURCE_REMOVE;
}
void ms_daemonize_complete(int notify_fd)
{
- LOGW("Enter");
+ LOGD("Enter");
muse_return_if_fail(muse_core_fd_is_valid(notify_fd));
#endif
write(notify_fd, MSG_DONE, strlen(MSG_DONE) + 1);
- LOGI("[%d] Notify parent process that child initialization is done", notify_fd);
+ LOGW("[%d] Notify parent process that child initialization is done", notify_fd);
close(notify_fd);
- LOGW("Leave");
+ LOGD("Leave");
}
void ms_gst_init(char **cmd)