gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26284 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r26284 - in gnunet/src: include util
Date: Mon, 4 Mar 2013 05:53:31 +0100

Author: grothoff
Date: 2013-03-04 05:53:31 +0100 (Mon, 04 Mar 2013)
New Revision: 26284

Modified:
   gnunet/src/include/gnunet_time_lib.h
   gnunet/src/util/common_logging.c
   gnunet/src/util/time.c
Log:
-include time offsets in logging as well

Modified: gnunet/src/include/gnunet_time_lib.h
===================================================================
--- gnunet/src/include/gnunet_time_lib.h        2013-03-04 04:34:11 UTC (rev 
26283)
+++ gnunet/src/include/gnunet_time_lib.h        2013-03-04 04:53:31 UTC (rev 
26284)
@@ -465,6 +465,15 @@
 GNUNET_TIME_set_offset (long long offset);
 
 
+/**
+ * Get the timestamp offset for this instance.
+ *
+ * @return the offset we currently skew the locale time by
+ */
+long long 
+GNUNET_TIME_get_offset (void);
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: gnunet/src/util/common_logging.c
===================================================================
--- gnunet/src/util/common_logging.c    2013-03-04 04:34:11 UTC (rev 26283)
+++ gnunet/src/util/common_logging.c    2013-03-04 04:53:31 UTC (rev 26284)
@@ -886,11 +886,14 @@
   memset (date, 0, DATE_STR_SIZE);
   {
     char buf[size];
+    long long offset;
 #ifdef WINDOWS
     LARGE_INTEGER pc;
     time_t timetmp;
 
+    offset = GNUNET_TIME_get_offset ();
     time (&timetmp);
+    timetmp += offset / 1000;
     tmptr = localtime (&timetmp);
     pc.QuadPart = 0;
     QueryPerformanceCounter (&pc);
@@ -909,6 +912,30 @@
     struct timeval timeofday;
 
     gettimeofday (&timeofday, NULL);
+    offset = GNUNET_TIME_get_offset ();
+    if (offset > 0)
+    {
+      timeofday.tv_sec += offset / 1000LL;
+      timeofday.tv_usec += (offset % 1000LL) * 1000LL;
+      if (timeofday.tv_usec > 1000000LL)
+      {
+       timeofday.tv_usec -= 1000000LL;
+       timeofday.tv_sec++;
+      }
+    }
+    else
+    {
+      timeofday.tv_sec += offset / 1000LL;
+      if (timeofday.tv_usec > - (offset % 1000LL) * 1000LL)
+      {
+       timeofday.tv_usec += (offset % 1000LL) * 1000LL;
+      }
+      else
+      {
+       timeofday.tv_usec += 1000000LL + (offset % 1000LL) * 1000LL;
+       timeofday.tv_sec--;
+      }
+    }
     tmptr = localtime (&timeofday.tv_sec);
     if (NULL == tmptr)
     {

Modified: gnunet/src/util/time.c
===================================================================
--- gnunet/src/util/time.c      2013-03-04 04:34:11 UTC (rev 26283)
+++ gnunet/src/util/time.c      2013-03-04 04:53:31 UTC (rev 26284)
@@ -46,6 +46,18 @@
 
 
 /**
+ * Get the timestamp offset for this instance.
+ *
+ * @return the offset we currently skew the locale time by
+ */
+long long 
+GNUNET_TIME_get_offset ()
+{
+  return timestamp_offset;
+}
+
+
+/**
  * Get the current time (works just as "time", just that we use the
  * unit of time that the cron-jobs use (and is 64 bit)).
  *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]