Add two fixes to the new geoip-db-digest line.

This commit is contained in:
Karsten Loesing 2010-11-12 09:06:27 +01:00
parent 423c2a7a27
commit 8833381d9c
2 changed files with 13 additions and 12 deletions

View File

@ -289,7 +289,9 @@ geoip_is_loaded(void)
return geoip_countries != NULL && geoip_entries != NULL;
}
/** Return the hex-encoded SHA1 digest of the loaded GeoIP file. */
/** Return the hex-encoded SHA1 digest of the loaded GeoIP file. The
* result does not need to be deallocated, but will be overwritten by the
* next call of hex_str(). */
const char *
geoip_db_digest(void)
{

View File

@ -2012,20 +2012,19 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
if (result<0)
return -1;
if (geoip_is_loaded()) {
if (tor_snprintf(s + strlen(s), maxlen - strlen(s),
"geoip-db-digest %s\n",
geoip_db_digest()) < 0) {
log_warn(LD_DIR, "Could not write geoip-db-digest to extra-info "
"descriptor.");
return -1;
}
}
if (options->ExtraInfoStatistics && write_stats_to_extrainfo) {
char *contents = NULL;
log_info(LD_GENERAL, "Adding stats to extra-info descriptor.");
if (geoip_is_loaded()) {
size_t pos = strlen(s);
if (tor_snprintf(s + pos, maxlen - strlen(s),
"geoip-db-digest %s\n",
geoip_db_digest()) < 0) {
log_warn(LD_DIR, "Could not write geoip-db-digest to extra-info "
"descriptor.");
s[pos] = '\0';
write_stats_to_extrainfo = 0;
}
}
if (options->DirReqStatistics &&
load_stats_file("stats"PATH_SEPARATOR"dirreq-stats",
"dirreq-stats-end", now, &contents) > 0) {