Eventually delete the obsolete cached-routers and cached-routers.new files, so they don't sit around on disk forever.
svn:r11918
it. Extra descriptors without any real changes are dropped by the
authorities, and can screw up our "publish every 18 hours" schedule.
+ o Minor features:
+ - If we find a cached-routers file that's been sitting around for more
+ than 28 days unmodified, then most likely it's a leftover from when we
+ upgraded to 0.2.0.8-alpha. Remove it. It has no good routers anyway.
+
o Code simplifications and refactoring:
- Remove support for the old bw_accounting file: we've been storing
bandwidth accounting information in the state file since 0.1.2.5-alpha.
return 0;
}
+/** Given a file name check to see whether the file exists but has not been
+ * modified for a very long time. If so, remove it. */
+void
+remove_file_if_very_old(const char *fname, time_t now)
+{
+#define VERY_OLD_FILE_AGE (28*24*60*60)
+ struct stat st;
+
+ if (stat(fname, &st)==0 && st.st_mtime < now-VERY_OLD_FILE_AGE) {
+ char buf[ISO_TIME_LEN+1];
+ format_local_iso_time(buf, st.st_mtime);
+ log_notice(LD_GENERAL, "Obsolete file %s hasn't been modified since %s. "
+ "Removing it.", fname, buf);
+ unlink(fname);
+ }
+}
+
/** Helper to implement GETINFO functions about configuration variables (not
* their values). Given a "config/names" question, set *<b>answer</b> to a
* new string describing the supported configuration variables and their
void assert_connection_ok(connection_t *conn, time_t now);
int connection_or_nonopen_was_started_here(or_connection_t *conn);
void connection_dump_buffer_mem_stats(int severity);
+void remove_file_if_very_old(const char *fname, time_t now);
/********************************* connection_edge.c *************************/
struct stat st;
int read_from_old_location = 0;
int extrainfo = (store->type == EXTRAINFO_STORE);
+ time_t now = time(NULL);
store->journal_len = store->store_len = 0;
tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"%s",
if ((store->mmap = tor_mmap_file(altname)))
read_from_old_location = 1;
}
+ if (altname && !read_from_old_location) {
+ remove_file_if_very_old(altname, now);
+ }
if (store->mmap) {
store->store_len = store->mmap->size;
if (extrainfo)
options->DataDirectory, store->fname_base);
if (file_status(fname) == FN_FILE)
contents = read_file_to_str(fname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
- if (!contents && read_from_old_location) {
+ if (read_from_old_location) {
tor_snprintf(altname, fname_len, "%s"PATH_SEPARATOR"%s.new",
options->DataDirectory, store->fname_alt_base);
- contents = read_file_to_str(altname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
+ if (!contents)
+ contents = read_file_to_str(altname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
+ else
+ remove_file_if_very_old(altname, now);
}
if (contents) {
if (extrainfo)