[Svace] Use localtime_r function for thread safety 53/99453/2 submit/tizen_3.0/20161123.074158
authorYoungHun Kim <yh8004.kim@samsung.com>
Wed, 23 Nov 2016 02:27:30 +0000 (11:27 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Wed, 23 Nov 2016 05:48:37 +0000 (14:48 +0900)
Change-Id: Ic3fe4099d9f6cdcc4a656b0a273ce0df81777355

packaging/mused.spec
src/muse_core_log.c

index c10ba6c..04ba089 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A Multimedia Daemon in Tizen Native API
-Version:    0.1.31
+Version:    0.1.32
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index d6a8ff1..51b0396 100644 (file)
@@ -491,13 +491,25 @@ static void _muse_core_log_cache_latest_msg(char *msg)
        g_return_if_fail(msg);
        g_return_if_fail(g_muse_core_log);
 
+#if defined(HAVE_LOCALTIME_R)
+       struct tm newtime;
+#endif
+
+       struct tm* ptm;
        struct timeval tv;
        char time_buf[MUSE_LOG_LEN];
 
        g_mutex_lock(&g_muse_core_log->log_lock);
 
        gettimeofday(&tv, NULL);
-       strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", localtime(&(tv.tv_sec)));
+
+#if defined(HAVE_LOCALTIME_R)
+       ptm = localtime_r(&(tv.tv_sec), &newtime);
+#else
+       ptm = localtime(&(tv.tv_sec));
+#endif
+
+       strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", ptm);
        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);
 
        g_muse_core_log->currnt_index = (g_muse_core_log->currnt_index + 1) % MUSE_LOG_MSG_NUM;