From 0ec400ac5b0d93d59e5c2059bc817ab94f7239e3 Mon Sep 17 00:00:00 2001
From: Gergo Ujhelyi <ujhelyi.gergo@ericsson.com>
Date: Thu, 23 Jul 2020 18:14:13 +0200
Subject: [PATCH] Bug 563289 - Fixed timestamp problem after 2038

Signed-off-by: Gergo Ujhelyi <ujhelyi.gergo@ericsson.com>
---
 core/LegacyLogger.cc        | 4 ++--
 core/LoggerPluginManager.cc | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/LegacyLogger.cc b/core/LegacyLogger.cc
index 252a6f9c2..b2a26dede 100644
--- a/core/LegacyLogger.cc
+++ b/core/LegacyLogger.cc
@@ -405,7 +405,7 @@ boolean LegacyLogger::log_console(const TitanLoggerApi::TitanLogEvent& event,
     return FALSE;
   }
   size_t event_str_len = mstrlen(event_str);
-  if (!TTCN_Communication::send_log((time_t)event.timestamp__().seconds(),
+  if (!TTCN_Communication::send_log((time_t)event.timestamp__().seconds().get_long_long_val(),
       (suseconds_t)event.timestamp__().microSeconds(), severity,
       event_str_len, event_str)) {
     // The event text shall be printed to stderr when there is no control
@@ -1774,7 +1774,7 @@ char *event_to_str(const TitanLoggerApi::TitanLogEvent& event,
 {
   char *ret_val = NULL;
   if (!without_header) {
-    struct timeval timestamp = { (time_t)event.timestamp__().seconds(),
+    struct timeval timestamp = { (time_t)event.timestamp__().seconds().get_long_long_val(),
       (suseconds_t)event.timestamp__().microSeconds() };
     char *sourceinfo = NULL;
     if (event.sourceInfo__list().is_bound()) {
diff --git a/core/LoggerPluginManager.cc b/core/LoggerPluginManager.cc
index 1cfb678eb..ac4d10ba8 100644
--- a/core/LoggerPluginManager.cc
+++ b/core/LoggerPluginManager.cc
@@ -532,7 +532,8 @@ void LoggerPluginManager::fill_common_fields(API::TitanLogEvent& event,
   struct timeval tv;
   if (gettimeofday(&tv, NULL) < 0)
     TTCN_Logger::fatal_error("The gettimeofday() system call failed.");
-  event.timestamp__() = API::TimestampType(tv.tv_sec, tv.tv_usec);
+  event.timestamp__().seconds().set_long_long_val(tv.tv_sec);
+  event.timestamp__().microSeconds()=tv.tv_usec;
   TTCN_Logger::source_info_format_t source_info_format =
     TTCN_Logger::get_source_info_format();
   API::TitanLogEvent_sourceInfo__list& srcinfo = event.sourceInfo__list();
-- 
GitLab