[or-cvs] Oops. conn->requested_resource is client only.

Nick Mathewson nickm at seul.org
Sun Jun 18 07:55:06 UTC 2006


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv6381/src/or

Modified Files:
	dirserv.c or.h 
Log Message:
Oops. conn->requested_resource is client only.

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.333
retrieving revision 1.334
diff -u -p -d -r1.333 -r1.334
--- dirserv.c	18 Jun 2006 07:38:55 -0000	1.333
+++ dirserv.c	18 Jun 2006 07:55:04 -0000	1.334
@@ -1750,12 +1750,7 @@ dirserv_orconn_tls_done(const char *addr
 static int
 connection_dirserv_add_servers_to_outbuf(connection_t *conn)
 {
-  int fp;
-
-  if (!strcmpstart(conn->requested_resource, "/tor/server/d/"))
-    fp = 0;
-  else
-    fp = 1;
+  int fp = conn->dir_refresh_src == DIR_REFRESH_SERVER_BY_FP;
 
   while (smartlist_len(conn->fingerprint_stack) &&
          buf_datalen(conn->outbuf) < DIRSERV_BUFFER_MIN) {
@@ -1842,16 +1837,16 @@ connection_dirserv_flushed_some(connecti
   tor_assert(conn->type == CONN_TYPE_DIR);
   tor_assert(conn->state == DIR_CONN_STATE_SERVER_WRITING);
 
-  if (! (conn->fingerprint_stack || conn->cached_dir)
+  if (conn->dir_refresh_src == DIR_REFRESH_NONE
       || buf_datalen(conn->outbuf) > DIRSERV_BUFFER_MIN)
     return 0;
 
-  if (!strcmpstart(conn->requested_resource, "/tor/server/")) {
-    return connection_dirserv_add_servers_to_outbuf(conn);
-  } else if (conn->cached_dir) {
-    return connection_dirserv_add_dir_bytes_to_outbuf(conn);
-  } else {
-    return 0;
+  switch (conn->dir_refresh_src) {
+    case DIR_REFRESH_SERVER_BY_DIGEST:
+    case DIR_REFRESH_SERVER_BY_FP:
+      return connection_dirserv_add_servers_to_outbuf(conn);
+    case DIR_REFRESH_CACHED_DIR:
+      return connection_dirserv_add_dir_bytes_to_outbuf(conn);
   }
 }
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.841
retrieving revision 1.842
diff -u -p -d -r1.841 -r1.842
--- or.h	18 Jun 2006 07:38:55 -0000	1.841
+++ or.h	18 Jun 2006 07:55:04 -0000	1.842
@@ -698,6 +698,10 @@ struct connection_t {
   char *requested_resource; /**< Which 'resource' did we ask the directory
                              * for?*/
 /* Used only for server sides of some dir connections. */
+  enum {
+    DIR_REFRESH_NONE=0, DIR_REFRESH_SERVER_BY_DIGEST, DIR_REFRESH_SERVER_BY_FP,
+    DIR_REFRESH_CACHED_DIR
+  } dir_refresh_src;
   smartlist_t *fingerprint_stack;
   struct cached_dir_t *cached_dir;
   off_t cached_dir_offset;



More information about the tor-commits mailing list