mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
fix two bugs with cached directories:
- don't complain that you won't cache it, then cache it anyway. - change confusing terminology from 'deflate' to 'compress', so we'll stop getting our logic backwards. i assume the rfc author has shot himself by now. svn:r2382
This commit is contained in:
parent
6e7e880438
commit
d0edf8e8b5
@ -643,7 +643,7 @@ void dirserv_set_cached_directory(const char *directory, time_t when)
|
||||
log_fn(LOG_INFO, "Ignoring old directory; not caching.");
|
||||
} else if (when>=now+ROUTER_ALLOW_SKEW) {
|
||||
log_fn(LOG_INFO, "Ignoring future directory; not caching.");
|
||||
} if (when>cached_directory_published &&
|
||||
} else if (when>cached_directory_published &&
|
||||
when<now+ROUTER_ALLOW_SKEW) {
|
||||
log_fn(LOG_DEBUG, "Caching directory.");
|
||||
tor_free(cached_directory);
|
||||
@ -667,12 +667,12 @@ void dirserv_set_cached_directory(const char *directory, time_t when)
|
||||
|
||||
/** Set *<b>directory</b> to the most recently generated encoded signed
|
||||
* directory, generating a new one as necessary. */
|
||||
size_t dirserv_get_directory(const char **directory, int deflate)
|
||||
size_t dirserv_get_directory(const char **directory, int compress)
|
||||
{
|
||||
if (!options.AuthoritativeDir) {
|
||||
if (deflate?cached_directory:cached_directory_z) {
|
||||
*directory = deflate?cached_directory:cached_directory_z;
|
||||
return (size_t) (deflate?cached_directory_len:cached_directory_z_len);
|
||||
if (compress?cached_directory_z:cached_directory) {
|
||||
*directory = compress?cached_directory_z:cached_directory;
|
||||
return (size_t) (compress?cached_directory_z_len:cached_directory_len);
|
||||
} else {
|
||||
/* no directory yet retrieved */
|
||||
return 0;
|
||||
@ -685,8 +685,8 @@ size_t dirserv_get_directory(const char **directory, int deflate)
|
||||
} else {
|
||||
log(LOG_INFO,"Directory still clean, reusing.");
|
||||
}
|
||||
*directory = deflate ? the_directory_z : the_directory;
|
||||
return deflate ? the_directory_z_len : the_directory_len;
|
||||
*directory = compress ? the_directory_z : the_directory;
|
||||
return compress ? the_directory_z_len : the_directory_len;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1184,7 +1184,7 @@ void dirserv_remove_old_servers(int age);
|
||||
int dirserv_dump_directory_to_string(char *s, unsigned int maxlen,
|
||||
crypto_pk_env_t *private_key);
|
||||
void directory_set_dirty(void);
|
||||
size_t dirserv_get_directory(const char **cp, int deflate);
|
||||
size_t dirserv_get_directory(const char **cp, int compress);
|
||||
size_t dirserv_get_runningrouters(const char **rr);
|
||||
void dirserv_set_cached_directory(const char *directory, time_t when);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user