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

[or-cvs] r18288: {tor} clean up r18287 (in tor/trunk: . src/or)



Author: arma
Date: 2009-01-28 02:16:22 -0500 (Wed, 28 Jan 2009)
New Revision: 18288

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/control.c
   tor/trunk/src/or/router.c
Log:
clean up r18287


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2009-01-28 06:50:36 UTC (rev 18287)
+++ tor/trunk/ChangeLog	2009-01-28 07:16:22 UTC (rev 18288)
@@ -1,4 +1,4 @@
-Changes in version 0.2.1.12-alpha - 2009-01-??
+Changes in version 0.2.1.12-alpha - 2009-02-??
   o Minor bugfixes:
     - Let controllers actually ask for the "clients_seen" event. Bugfix
       on 0.2.1.10-alpha; reported by Matt Edman.
@@ -14,7 +14,9 @@
 
   o Minor features:
     - Support platforms where time_t is 64 bits long. (Congratulations,
-      NetBSD!)  Patch from Matthias Drochner.
+      NetBSD!) Patch from Matthias Drochner.
+    - Add a 'getinfo status/clients-seen' controller command, in case
+      controllers want to hear clients_seen events but connect late.
 
 
 Changes in version 0.2.1.11-alpha - 2009-01-20

Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c	2009-01-28 06:50:36 UTC (rev 18287)
+++ tor/trunk/src/or/control.c	2009-01-28 07:16:22 UTC (rev 18288)
@@ -1839,23 +1839,20 @@
       }
     } else if (!strcmp(question, "status/clients-seen")) {
       char geoip_start[ISO_TIME_LEN+1];
-      char *geoip_summary;
-      smartlist_t *sl;
+      size_t answer_len;
+      char *geoip_summary = extrainfo_get_client_geoip_summary(time(NULL));
 
-      geoip_summary = extrainfo_get_client_geoip_summary(time(NULL));
       if (!geoip_summary)
         return -1;
-      format_iso_time(geoip_start, geoip_get_history_start());
 
-      sl = smartlist_create();
-      smartlist_add(sl, (char *)"TimeStarted=\"");
-      smartlist_add(sl, geoip_start);
-      smartlist_add(sl, (char *)"\" CountrySummary=");
-      smartlist_add(sl, geoip_summary);
-      *answer = smartlist_join_strings(sl, "", 0, 0);
-
+      answer_len = strlen("TimeStarted=\"\" CountrySummary=") +
+                   ISO_TIME_LEN + strlen(geoip_summary) + 1;
+      *answer = tor_malloc(answer_len);
+      format_iso_time(geoip_start, geoip_get_history_start());
+      tor_snprintf(*answer, answer_len,
+                   "TimeStarted=\"%s\" CountrySummary=%s",
+                   geoip_start, geoip_summary);
       tor_free(geoip_summary);
-      smartlist_free(sl);
     } else {
       return 0;
     }

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2009-01-28 06:50:36 UTC (rev 18287)
+++ tor/trunk/src/or/router.c	2009-01-28 07:16:22 UTC (rev 18288)
@@ -1906,11 +1906,12 @@
   return (int)strlen(s)+1;
 }
 
-/** Return a newly allocated comma-separated string containing entries for all
- * the countries from which we've seen enough clients connect over the
- * previous 48 hours. The entry format is cc=num where num is the number of
- * IPs we've seen connecting from that country, and cc is a lowercased
- * country code. Returns NULL if we don't want to export geoip data yet. */
+/** Wrapper function for geoip_get_client_history(). It first discards
+ * any items in the client history that are too old -- it dumps anything
+ * more than 48 hours old, but it only considers whether to dump at most
+ * once per 48 hours, so we aren't too precise to an observer (see also
+ * r14780).
+ */
 char *
 extrainfo_get_client_geoip_summary(time_t now)
 {