]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Replace files in stats/ rather than appending to them.
authorKarsten Loesing <karsten.loesing@gmx.net>
Thu, 4 Aug 2011 18:53:53 +0000 (20:53 +0200)
committerKarsten Loesing <karsten.loesing@gmx.net>
Thu, 4 Aug 2011 18:57:29 +0000 (20:57 +0200)
Right now, we append statistics to files in the stats/ directory for
half of the statistics, whereas we overwrite these files for the other
half. In particular, we append buffer, dirreq, and entry stats and
overwrite exit, connection, and bridge stats.

Appending to files was useful when we didn't include stats in extra-info
descriptors, because otherwise we'd have to copy them away to prevent
Tor from overwriting them.

But now that we include statistics in extra-info descriptors, it makes
no sense to keep the old statistics forever. We should change the
behavior to overwriting instead of appending for all statistics.

Implements #2930.

changes/bug2930 [new file with mode: 0644]
src/or/geoip.c
src/or/rephist.c

diff --git a/changes/bug2930 b/changes/bug2930
new file mode 100644 (file)
index 0000000..8d28664
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor features:
+    - Replace files in stats/ rather than appending to them.  Now that we
+      include statistics in extra-info descriptors, it makes no sense to
+      keep old statistics forever.  Implements #2930.
+
index 5596ff32530e6e76d0c807f0d76684849fb6892b..d02666bf9526e4511efb210103afa899a1c90637 100644 (file)
@@ -996,7 +996,7 @@ geoip_dirreq_stats_write(time_t now)
   data_v2 = geoip_get_client_history(GEOIP_CLIENT_NETWORKSTATUS_V2);
   data_v3 = geoip_get_client_history(GEOIP_CLIENT_NETWORKSTATUS);
   format_iso_time(written, now);
-  out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND | O_TEXT,
+  out = start_writing_to_stdio_file(filename, OPEN_FLAGS_REPLACE | O_TEXT,
                                     0600, &open_file);
   if (!out)
     goto done;
@@ -1329,7 +1329,7 @@ geoip_entry_stats_write(time_t now)
   filename = get_datadir_fname2("stats", "entry-stats");
   data = geoip_get_client_history(GEOIP_CLIENT_CONNECT);
   format_iso_time(written, now);
-  out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND | O_TEXT,
+  out = start_writing_to_stdio_file(filename, OPEN_FLAGS_REPLACE | O_TEXT,
                                     0600, &open_file);
   if (!out)
     goto done;
index 1ad08fe93e5d46242cdd5c012a0acdf4f0f9f448..672e3f3dafceec3e56eb4c25b7c56f85e71a5ac6 100644 (file)
@@ -2490,7 +2490,7 @@ rep_hist_buffer_stats_write(time_t now)
   if (check_private_dir(statsdir, CPD_CREATE, get_options()->User) < 0)
     goto done;
   filename = get_datadir_fname2("stats", "buffer-stats");
-  out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND | O_TEXT,
+  out = start_writing_to_stdio_file(filename, OPEN_FLAGS_REPLACE | O_TEXT,
                                     0600, &open_file);
   if (!out)
     goto done;