summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-02-01 18:09:27 +0000
committerNick Mathewson <nickm@torproject.org>2007-02-01 18:09:27 +0000
commit5cb99857bc0633757f60c4b964359c5a03121b28 (patch)
tree707a2ad60ab69f54eb9e4716d0fa9df50c77686f /src/or
parent8a9a55251ffe14389a96e99bdcc7af59b0f1c8ba (diff)
downloadtor-5cb99857bc0633757f60c4b964359c5a03121b28.tar.gz
tor-5cb99857bc0633757f60c4b964359c5a03121b28.zip
r11620@catbus: nickm | 2007-02-01 13:06:27 -0500
Call stat() slightly less often; use fstat() when possible. svn:r9472
Diffstat (limited to 'src/or')
-rw-r--r--src/or/dns.c4
-rw-r--r--src/or/routerlist.c7
2 files changed, 4 insertions, 7 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index 3137a67de8..c86bd9c571 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -1529,8 +1529,8 @@ configure_nameservers(int force)
evdns_set_log_fn(evdns_log_cb);
if (conf_fname) {
if (stat(conf_fname, &st)) {
- log_warn(LD_EXIT, "Unable to stat resolver configuration in '%s'",
- conf_fname);
+ log_warn(LD_EXIT, "Unable to stat resolver configuration in '%s': %s",
+ conf_fname, strerror(errno));
return -1;
}
if (!force && resolv_conf_fname && !strcmp(conf_fname,resolv_conf_fname)
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index f177b153a0..46b958d9dc 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -118,8 +118,8 @@ int
router_reload_networkstatus(void)
{
char filename[512];
- struct stat st;
smartlist_t *entries;
+ struct stat st;
char *s;
tor_assert(get_options()->DataDirectory);
if (!networkstatus_list)
@@ -138,9 +138,8 @@ router_reload_networkstatus(void)
}
tor_snprintf(filename,sizeof(filename),"%s/cached-status/%s",
get_options()->DataDirectory, fn);
- s = read_file_to_str(filename, 0, NULL);
+ s = read_file_to_str(filename, 0, &st);
if (s) {
- stat(filename, &st);
if (router_set_networkstatus(s, st.st_mtime, NS_FROM_CACHE, NULL)<0) {
log_warn(LD_FS, "Couldn't load networkstatus from \"%s\"",filename);
}
@@ -353,7 +352,6 @@ router_reload_router_list(void)
or_options_t *options = get_options();
size_t fname_len = strlen(options->DataDirectory)+32;
char *fname = tor_malloc(fname_len), *contents;
- struct stat st;
if (!routerlist)
router_get_routerlist(); /* mallocs and inits it in place */
@@ -376,7 +374,6 @@ router_reload_router_list(void)
options->DataDirectory);
contents = read_file_to_str(fname, 1, NULL);
if (contents) {
- stat(fname, &st);
router_load_routers_from_string(contents,
SAVED_IN_JOURNAL, NULL);
tor_free(contents);