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

[or-cvs] r9146: Remove an artificial upper bound on expected bandwidth. More (in tor/trunk: . src/or)



Author: nickm
Date: 2006-12-17 11:37:46 -0500 (Sun, 17 Dec 2006)
New Revision: 9146

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/hibernate.c
Log:
 r11627@Kushana:  nickm | 2006-12-17 11:37:39 -0500
 Remove an artificial upper bound on expected bandwidth.  More immediately, fix a VC warning.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11627] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-12-17 10:25:39 UTC (rev 9145)
+++ tor/trunk/ChangeLog	2006-12-17 16:37:46 UTC (rev 9146)
@@ -56,6 +56,9 @@
     - Routers no longer ever list themselves in their "family" line,
       even if configured to do so.  This makes it easier to configure
       family lists efficiently.
+    - Remove an artificial (but quite high) restriction on expected
+      bandwidth, so that accounting won't break once we all have gigabit
+      connections to our homes.
 
   o Controller features:
     - Have GETINFO dir/status/* work on hosts with DirPort disabled.

Modified: tor/trunk/src/or/hibernate.c
===================================================================
--- tor/trunk/src/or/hibernate.c	2006-12-17 10:25:39 UTC (rev 9145)
+++ tor/trunk/src/or/hibernate.c	2006-12-17 16:37:46 UTC (rev 9146)
@@ -82,7 +82,7 @@
 static time_t interval_wakeup_time = 0;
 /** How much bandwidth do we 'expect' to use per minute?  (0 if we have no
  * info from the last period.) */
-static uint32_t expected_bandwidth_usage = 0;
+static uint64_t expected_bandwidth_usage = 0;
 /** What unit are we using for our accounting? */
 static time_unit_t cfg_unit = UNIT_MONTH;
 /** How many days,hours,minutes into each unit does our accounting interval
@@ -366,9 +366,7 @@
     if (expected > max_configured)
       expected = max_configured;
   }
-  if (expected > UINT32_MAX)
-    expected = UINT32_MAX;
-  expected_bandwidth_usage = (uint32_t) expected;
+  expected_bandwidth_usage = expected;
 }
 
 /** Called at the start of a new accounting interval: reset our
@@ -545,6 +543,7 @@
   char *cp = buf;
   time_t tmp;
   int r;
+  uint64_t expected;
 
   /* First, update bw_accounting. Until 0.1.2.5-x, this was the only place
    * we stored this information. The format is:
@@ -558,6 +557,10 @@
     log_warn(LD_ACCT, "Created a time that we refused to parse.");
     return -1;
   }
+  expected = expected_bandwidth_usage;
+  /* Cap this value, since older versions won't parse a uint64_t here. */
+  if (expected > UINT32_MAX)
+    expected = UINT32_MAX;
   tor_snprintf(cp, sizeof(buf),
                "%d\n%s\n%s\n"U64_FORMAT"\n"U64_FORMAT"\n%lu\n%lu\n",
                BW_ACCOUNTING_VERSION,
@@ -566,7 +569,7 @@
                U64_PRINTF_ARG(ROUND_UP(n_bytes_read_in_interval)),
                U64_PRINTF_ARG(ROUND_UP(n_bytes_written_in_interval)),
                (unsigned long)n_seconds_active_in_interval,
-               (unsigned long)expected_bandwidth_usage);
+               (unsigned long)expected);
   tor_snprintf(fname, sizeof(fname), "%s/bw_accounting",
                get_options()->DataDirectory);
   r = write_str_to_file(fname, buf, 0);
@@ -685,7 +688,7 @@
        (char*)smartlist_get(elts,2),
        (char*)smartlist_get(elts,1),
        (unsigned long)n_seconds_active_in_interval,
-       (unsigned long)((uint64_t)expected_bandwidth_usage*1024/60),
+       (unsigned long)(expected_bandwidth_usage*1024/60),
        U64_PRINTF_ARG(n_bytes_read_in_interval),
        U64_PRINTF_ARG(n_bytes_written_in_interval));