[or-cvs] r13638: Resolve all DOCDOC issues, and document some other undocumen (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Thu Feb 21 03:38:47 UTC 2008


Author: nickm
Date: 2008-02-20 22:38:46 -0500 (Wed, 20 Feb 2008)
New Revision: 13638

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/compat.c
   tor/trunk/src/common/compat.h
   tor/trunk/src/or/config.c
   tor/trunk/src/or/connection_edge.c
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/main.c
Log:
 r18291 at catbus:  nickm | 2008-02-20 22:35:32 -0500
 Resolve all DOCDOC issues, and document some other undocumented code, and fix a changelog entry.



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

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-02-21 03:38:44 UTC (rev 13637)
+++ tor/trunk/ChangeLog	2008-02-21 03:38:46 UTC (rev 13638)
@@ -14,9 +14,9 @@
       by nwf; bugfix on 0.1.2.x.
     - When counting the number of open sockets, count not only the number
       of sockets we have received from the socket() call, but also the
-      number we've gotten from accept().  This bug made us fail to count
-      all sockets that we were using for incoming connections.  Bugfix on
-      0.2.0.x
+      number we've gotten from accept() and socketpair().  This bug made us
+      fail to count all sockets that we were using for incoming
+      connections.  Bugfix on 0.2.0.x.
     - Fix code used to find strings within buffers, when those strings
       are not in the first chunk of the buffer.
     - Fix potential segfault when parsing HTTP headers. Bugfix on 0.2.0.x.

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2008-02-21 03:38:44 UTC (rev 13637)
+++ tor/trunk/src/common/compat.c	2008-02-21 03:38:46 UTC (rev 13638)
@@ -489,7 +489,10 @@
 
 #undef DEBUG_SOCKET_COUNTING
 #ifdef DEBUG_SOCKET_COUNTING
+/** A bitarray of all fds that should be passed to tor_socket_close(). Only
+ * used if DEBUG_SOCKET_COUNTING is defined. */
 static bitarray_t *open_sockets = NULL;
+/** The size of <b>open_sockets</b>, in bits. */
 static int max_socket = -1;
 #endif
 
@@ -547,6 +550,8 @@
 }
 
 #ifdef DEBUG_SOCKET_COUNTING
+/** Helper: if DEBUG_SOCKET_COUNTING is enabled, remember that <b>s</b> is
+ * now an open socket. */
 static INLINE void
 mark_socket_open(int s)
 {

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2008-02-21 03:38:44 UTC (rev 13637)
+++ tor/trunk/src/common/compat.h	2008-02-21 03:38:46 UTC (rev 13638)
@@ -331,7 +331,8 @@
 
 typedef uint8_t maskbits_t;
 struct in_addr;
-/** DOCDOC */
+/** Holds an IPv4 or IPv6 address.  (Uses less memory than struct
+ * sockaddr_storage.) */
 typedef struct tor_addr_t
 {
   sa_family_t family;

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2008-02-21 03:38:44 UTC (rev 13637)
+++ tor/trunk/src/or/config.c	2008-02-21 03:38:46 UTC (rev 13638)
@@ -2446,7 +2446,7 @@
   config_init(&options_format, options);
 }
 
-/* Set all vars in the configuration object 'options' to their default
+/** Set all vars in the configuration object 'options' to their default
  * values. */
 static void
 config_init(config_format_t *fmt, void *options)

Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2008-02-21 03:38:44 UTC (rev 13637)
+++ tor/trunk/src/or/connection_edge.c	2008-02-21 03:38:46 UTC (rev 13638)
@@ -2593,7 +2593,7 @@
  * conn, and join them together.  Return 0 on success (or if there was an
  * error we could send back an end cell for).  Return -(some circuit end
  * reason) if the circuit needs to be torn down.  Either connects
- * <b>exitconn<b/>, frees it, or marks it, as appropriate.
+ * <b>exitconn</b>, frees it, or marks it, as appropriate.
  */
 static int
 connection_exit_connect_dir(edge_connection_t *exitconn)

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2008-02-21 03:38:44 UTC (rev 13637)
+++ tor/trunk/src/or/dirserv.c	2008-02-21 03:38:46 UTC (rev 13638)
@@ -1614,6 +1614,7 @@
 /* Thresholds for server performance: set by
  * dirserv_compute_performance_thresholds, and used by
  * generate_v2_networkstatus */
+/* XXXX stick these all in a struct. */
 static uint32_t stable_uptime = 0; /* start at a safe value */
 static double stable_mtbf = 0.0;
 static int enough_mtbf_info = 0;
@@ -1687,12 +1688,14 @@
           router->is_running);
 }
 
-/** Look through the routerlist, and assign the median uptime of running valid
- * servers to stable_uptime, and the relative bandwidth capacities to
- * fast_bandwidth and guard_bandwidth.  Set total_bandwidth to the total
- * capacity of all running valid servers and total_exit_bandwidth to the
- * capacity of all running valid exits.  Set the is_exit flag of each router
- * appropriately. */
+/** Look through the routerlist, the Mean Time Between Failure history, and
+ * the Weighted Fractional Uptime history, and use them to set thresholds for
+ * the Stable, Fast, and Guard flags.  Update the fields stable_uptime,
+ * stable_mtbf, enough_mtbf_info, guard_wfu, guard_tk, fast_bandwidth,
+ * guard_bandwidh_including_exits, guard_bandwidth_excluding_exits,
+ * total_bandwidth, and total_exit_bandwidth.
+ *
+ * Also, set the is_exit flag of each router appropriately. */
 static void
 dirserv_compute_performance_thresholds(routerlist_t *rl)
 {
@@ -1702,8 +1705,6 @@
   double *mtbfs, *wfus;
   time_t now = time(NULL);
 
-  /* DOCDOC this is a litle tricky; comment this function better. */
-
   /* initialize these all here, in case there are no routers */
   stable_uptime = 0;
   stable_mtbf = 0;
@@ -1712,19 +1713,27 @@
   guard_bandwidth_excluding_exits = 0;
   guard_tk = 0;
   guard_wfu = 0;
-
   total_bandwidth = 0;
   total_exit_bandwidth = 0;
 
+  /* Initialize arrays that will hold values for each router.  We'll
+   * sort them and use that to compute thresholds. */
   n_active = n_active_nonexit = 0;
+  /* Uptime for every active router. */
   uptimes = tor_malloc(sizeof(uint32_t)*smartlist_len(rl->routers));
+  /* Bandwidth for every active router. */
   bandwidths = tor_malloc(sizeof(uint32_t)*smartlist_len(rl->routers));
+  /* Bandwidth for every active non-exit router. */
   bandwidths_excluding_exits =
     tor_malloc(sizeof(uint32_t)*smartlist_len(rl->routers));
+  /* Weighted mean time between failure for each active router. */
   mtbfs = tor_malloc(sizeof(double)*smartlist_len(rl->routers));
+  /* Time-known for each active router. */
   tks = tor_malloc(sizeof(long)*smartlist_len(rl->routers));
+  /* Weighted fractional uptime for each active router. */
   wfus = tor_malloc(sizeof(double)*smartlist_len(rl->routers));
 
+  /* Now, fill in the arrays. */
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
     if (router_is_active(ri, now)) {
       const char *id = ri->cache_info.identity_digest;
@@ -1745,11 +1754,15 @@
     }
   });
 
+  /* Now, compute thresholds. */
   if (n_active) {
+    /* The median uptime is stable. */
     stable_uptime = median_uint32(uptimes, n_active);
+    /* The median mtbf is stable, if we have enough mtbf info */
     stable_mtbf = median_double(mtbfs, n_active);
+    /* The 12.5th percentile bandwidth is fast. */
     fast_bandwidth = find_nth_uint32(bandwidths, n_active, n_active/8);
-    /* Now bandwidths is sorted. */
+    /* (Now bandwidths is sorted.) */
     if (fast_bandwidth < ROUTER_REQUIRED_MIN_BANDWIDTH)
       fast_bandwidth = bandwidths[n_active/4];
     guard_bandwidth_including_exits = bandwidths[(n_active-1)/2];
@@ -1762,6 +1775,8 @@
   if (fast_bandwidth > BANDWIDTH_TO_GUARANTEE_FAST)
     fast_bandwidth = BANDWIDTH_TO_GUARANTEE_FAST;
 
+  /* Now that we have a time-known that 7/8 routers are known longer than,
+   * fill wfus with the wfu of every such "familiar" router. */
   n_familiar = 0;
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
       if (router_is_active(ri, now)) {

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2008-02-21 03:38:44 UTC (rev 13637)
+++ tor/trunk/src/or/main.c	2008-02-21 03:38:46 UTC (rev 13638)
@@ -1473,11 +1473,6 @@
         continue;
       }
     }
-
-    /* refilling buckets and sending cells happens at the beginning of the
-     * next iteration of the loop, inside prepare_for_poll()
-     * DOCDOC No longer so; fix comment.
-     */
   }
 }
 



More information about the tor-commits mailing list