[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r11482: Split "Have all the authorities accepted our server descript (in tor/trunk: . src/or)



Author: nickm
Date: 2007-09-18 11:53:53 -0400 (Tue, 18 Sep 2007)
New Revision: 11482

Modified:
   tor/trunk/
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/or.h
Log:
 r15142@catbus:  nickm | 2007-09-18 11:43:32 -0400
 Split "Have all the authorities accepted our server descriptor?" into its own function.  Patch from Robert Hogan.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15142] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-09-18 15:45:49 UTC (rev 11481)
+++ tor/trunk/src/or/directory.c	2007-09-18 15:53:53 UTC (rev 11482)
@@ -183,6 +183,21 @@
   return 0;
 }
 
+/** Return true iff all trusted directory servers have accepted our
+ * server descriptor. */
+int
+directories_have_accepted_server_descriptor(void)
+{
+  smartlist_t *servers = router_get_trusted_dir_servers();
+  SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
+    if ((d->type & (V1_AUTHORITY|V2_AUTHORITY)) &&
+        !d->has_accepted_serverdesc) {
+      return 0;
+    }
+  });
+  return 1;
+}
+
 /** Start a connection to every suitable directory authority, using
  * connection purpose 'purpose' and uploading the payload 'payload'
  * (length 'payload_len').  The purpose should be one of
@@ -1400,10 +1415,8 @@
   if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_DIR) {
     switch (status_code) {
       case 200: {
-          int all_done = 1;
           trusted_dir_server_t *ds =
             router_get_trusteddirserver_by_digest(conn->identity_digest);
-          smartlist_t *servers;
           log_info(LD_GENERAL,"eof (status 200) after uploading server "
                    "descriptor: finished.");
           control_event_server_status(
@@ -1411,15 +1424,7 @@
                       conn->_base.address, conn->_base.port);
 
           ds->has_accepted_serverdesc = 1;
-          servers = router_get_trusted_dir_servers();
-          SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
-              if ((d->type & (V1_AUTHORITY|V2_AUTHORITY)) &&
-                  !d->has_accepted_serverdesc) {
-                all_done = 0;
-                break;
-              }
-            });
-          if (all_done)
+          if (directories_have_accepted_server_descriptor())
             control_event_server_status(LOG_NOTICE, "GOOD_SERVER_DESCRIPTOR");
         }
         break;

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-09-18 15:45:49 UTC (rev 11481)
+++ tor/trunk/src/or/or.h	2007-09-18 15:53:53 UTC (rev 11482)
@@ -2761,6 +2761,7 @@
 
 /********************************* directory.c ***************************/
 
+int directories_have_accepted_server_descriptor(void);
 char *authority_type_to_string(authority_type_t auth);
 void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
                                   authority_type_t type, const char *payload,