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

[or-cvs] r15105: a couple more geoip bugfixes (tor/trunk/src/or)



Author: nickm
Date: 2008-06-10 15:51:48 -0400 (Tue, 10 Jun 2008)
New Revision: 15105

Modified:
   tor/trunk/src/or/geoip.c
Log:
a couple more geoip bugfixes

Modified: tor/trunk/src/or/geoip.c
===================================================================
--- tor/trunk/src/or/geoip.c	2008-06-10 19:25:25 UTC (rev 15104)
+++ tor/trunk/src/or/geoip.c	2008-06-10 19:51:48 UTC (rev 15105)
@@ -291,6 +291,10 @@
   while (current_request_period_starts + REQUEST_HIST_PERIOD < now) {
     if (!geoip_countries)
       geoip_countries = smartlist_create();
+    if (!current_request_period_starts) {
+      current_request_period_starts = now;
+      break;
+    }
     SMARTLIST_FOREACH(geoip_countries, geoip_country_t *, c, {
         memmove(&c->n_v2_ns_requests[0], &c->n_v2_ns_requests[1],
                 sizeof(uint32_t)*(REQUEST_HIST_LEN-1));
@@ -300,9 +304,9 @@
         c->n_v3_ns_requests[REQUEST_HIST_LEN-1] = 0;
       });
     current_request_period_starts += REQUEST_HIST_PERIOD;
-    if (n_old_request_periods < REQUEST_HIST_PERIOD-1)
+    if (n_old_request_periods < REQUEST_HIST_LEN-1)
       ++n_old_request_periods;
-  }
+   }
 
   /* We use the low 3 bits of the time to encode the action. Since we're
    * potentially remembering tons of clients, we don't want to make