[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r14299: Make last_served_at optional; make last_listed_as_valid_unti (in tor/trunk: . src/or)
Author: nickm
Date: 2008-04-04 17:18:56 -0400 (Fri, 04 Apr 2008)
New Revision: 14299
Modified:
tor/trunk/
tor/trunk/src/or/dirserv.c
tor/trunk/src/or/networkstatus.c
tor/trunk/src/or/or.h
Log:
r19202@catbus: nickm | 2008-04-04 17:18:47 -0400
Make last_served_at optional; make last_listed_as_valid_until take account (partially) of v2 statuses.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r19202] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2008-04-04 21:18:51 UTC (rev 14298)
+++ tor/trunk/src/or/dirserv.c 2008-04-04 21:18:56 UTC (rev 14299)
@@ -2939,7 +2939,9 @@
static int
connection_dirserv_add_servers_to_outbuf(dir_connection_t *conn)
{
+#ifdef TRACK_SERVED_TIME
time_t now = time(NULL);
+#endif
int by_fp = (conn->dir_spool_src == DIR_SPOOL_SERVER_BY_FP ||
conn->dir_spool_src == DIR_SPOOL_EXTRA_BY_FP);
int extra = (conn->dir_spool_src == DIR_SPOOL_EXTRA_BY_FP ||
@@ -2967,7 +2969,9 @@
* unknown bridge descriptor has shown up between then and now. */
continue;
}
+#ifdef TRACK_SERVED_TIME
sd->last_served_at = now;
+#endif
body = signed_descriptor_get_body(sd);
if (conn->zlib_state) {
int last = ! smartlist_len(conn->fingerprint_stack);
Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c 2008-04-04 21:18:51 UTC (rev 14298)
+++ tor/trunk/src/or/networkstatus.c 2008-04-04 21:18:56 UTC (rev 14299)
@@ -697,11 +697,24 @@
if (!found)
smartlist_add(networkstatus_v2_list, ns);
- SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
+/*XXXX021 magic. */
+/*DOCDOC */
+#define V2_NETWORKSTATUS_LIFETIME (3*60*60)
+
+ {
+ time_t live_until = ns->published_on + V2_NETWORKSTATUS_LIFETIME;
+ SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
{
- if (!router_get_by_descriptor_digest(rs->descriptor_digest))
+ signed_descriptor_t *sd =
+ router_get_by_descriptor_digest(rs->descriptor_digest);
+ if (sd) {
+ if (sd->last_listed_as_valid_until < live_until)
+ sd->last_listed_as_valid_until = live_until;
+ } else {
rs->need_to_mirror = 1;
+ }
});
+ }
log_info(LD_DIR, "Setting networkstatus %s %s (published %s)",
source == NS_FROM_CACHE?"cached from":
@@ -1286,6 +1299,7 @@
if (old_remain)
rs_old = smartlist_get(old_c->routerstatus_list, idx);
+ /* XXXX021 candidate for a foreach_matched macro. */
SMARTLIST_FOREACH(new_c->routerstatus_list, routerstatus_t *, rs_new,
{
if (!old_remain) {
@@ -1323,6 +1337,7 @@
return;
rs_old = smartlist_get(old_c->routerstatus_list, idx);
+ /* XXXX021 candidate for a FOREACH_MATCHED macro. */
SMARTLIST_FOREACH(new_c->routerstatus_list, routerstatus_t *, rs_new,
{
int r;
@@ -1709,6 +1724,7 @@
idx = 0;
rs = smartlist_get(ns->routerstatus_list, idx);
+ /* Candidate for a FOREACH_MATCHED macro.XXX021 */
SMARTLIST_FOREACH(routers, routerinfo_t *, router,
{
const char *digest = router->cache_info.identity_digest;
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2008-04-04 21:18:51 UTC (rev 14298)
+++ tor/trunk/src/or/or.h 2008-04-04 21:18:56 UTC (rev 14299)
@@ -1219,10 +1219,14 @@
* routerlist->old_routers? -1 for none. */
int routerlist_index;
/** The valid-until time of the most recent consensus that listed this
- * descriptor. 0 for "never listed in a consensus, so far as we know." */
+ * descriptor, or a bit after the publication time of the most recent v2
+ * networkstatus that listed it. 0 for "never listed in a consensus or
+ * status, so far as we know." */
time_t last_listed_as_valid_until;
+#ifdef TRACK_SERVED_TIME
/** DOCDOC */
time_t last_served_at; /*XXXX021 remove if not useful. */
+#endif
/* If true, we do not ever try to save this object in the cache. */
unsigned int do_not_cache : 1;
/* If true, this item is meant to represent an extrainfo. */