[or-cvs] fix two bugs with cached directories:

Roger Dingledine arma at seul.org
Mon Sep 27 06:57:19 UTC 2004


Update of /home2/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv11411

Modified Files:
	dirserv.c or.h 
Log Message:
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.


Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- dirserv.c	23 Sep 2004 19:58:44 -0000	1.80
+++ dirserv.c	27 Sep 2004 06:57:16 -0000	1.81
@@ -643,7 +643,7 @@
     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 @@
 
 /** 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 @@
   } 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;
 }
 
 /**

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/src/or/or.h,v
retrieving revision 1.419
retrieving revision 1.420
diff -u -d -r1.419 -r1.420
--- or.h	27 Sep 2004 06:00:43 -0000	1.419
+++ or.h	27 Sep 2004 06:57:16 -0000	1.420
@@ -1184,7 +1184,7 @@
 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);
 



More information about the tor-commits mailing list