[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r18234: {tor} Support 64-bit time_t. Patch from Matthias Drochner. Partial (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2009-01-22 11:28:12 -0500 (Thu, 22 Jan 2009)
New Revision: 18234

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/common/torint.h
   tor/trunk/src/common/util.c
   tor/trunk/src/or/circuituse.c
   tor/trunk/src/or/main.c
Log:
Support 64-bit time_t.  Patch from Matthias Drochner. Partial backport candidate.

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2009-01-22 15:37:56 UTC (rev 18233)
+++ tor/trunk/ChangeLog	2009-01-22 16:28:12 UTC (rev 18234)
@@ -10,7 +10,11 @@
       enabled when accounting was turned on.  Fixes bug 907.  Bugfix on
       0.0.9pre6.
 
+  o Minor features:
+    - Support platforms where time_t is 64 bits long. (Congratulations,
+      NetBSD!)  Patch from Matthias Drochner.
 
+
 Changes in version 0.2.1.11-alpha - 2009-01-20
   o Security fixes:
     - Fix a heap-corruption bug that may be remotely triggerable on

Modified: tor/trunk/src/common/torint.h
===================================================================
--- tor/trunk/src/common/torint.h	2009-01-22 15:37:56 UTC (rev 18233)
+++ tor/trunk/src/common/torint.h	2009-01-22 16:28:12 UTC (rev 18234)
@@ -288,6 +288,8 @@
 #define TIME_MAX ((time_t)INT_MAX)
 #elif (SIZEOF_TIME_T == SIZEOF_LONG)
 #define TIME_MAX ((time_t)LONG_MAX)
+#elif (SIZEOF_TIME_T == 8)
+#define TIME_MAX ((time_t)INT64_MAX)
 #else
 #error "Can't define (signed) TIME_MAX"
 #endif

Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c	2009-01-22 15:37:56 UTC (rev 18233)
+++ tor/trunk/src/common/util.c	2009-01-22 16:28:12 UTC (rev 18234)
@@ -1031,8 +1031,7 @@
   /* This is a pretty ironclad timegm implementation, snarfed from Python2.2.
    * It's way more brute-force than fiddling with tzset().
    */
-  time_t ret;
-  unsigned long year, days, hours, minutes;
+  time_t year, days, hours, minutes, seconds;
   int i;
   year = tm->tm_year + 1900;
   if (year < 1970 || tm->tm_mon < 0 || tm->tm_mon > 11) {
@@ -1049,8 +1048,8 @@
   hours = days*24 + tm->tm_hour;
 
   minutes = hours*60 + tm->tm_min;
-  ret = minutes*60 + tm->tm_sec;
-  return ret;
+  seconds = minutes*60 + tm->tm_sec;
+  return seconds;
 }
 
 /* strftime is locale-specific, so we need to replace those parts */

Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c	2009-01-22 15:37:56 UTC (rev 18233)
+++ tor/trunk/src/or/circuituse.c	2009-01-22 16:28:12 UTC (rev 18234)
@@ -530,7 +530,7 @@
 void
 circuit_build_needed_circs(time_t now)
 {
-  static long time_to_new_circuit = 0;
+  static time_t time_to_new_circuit = 0;
   or_options_t *options = get_options();
 
   /* launch a new circ for any pending streams that need one */

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2009-01-22 15:37:56 UTC (rev 18233)
+++ tor/trunk/src/or/main.c	2009-01-22 16:28:12 UTC (rev 18234)
@@ -1138,7 +1138,7 @@
    * could use libevent's timers for this rather than checking the current
    * time against a bunch of timeouts every second. */
   static struct timeval one_second;
-  static long current_second = 0;
+  static time_t current_second = 0;
   time_t now;
   size_t bytes_written;
   size_t bytes_read;