[or-cvs] Fix a few bugs in accounting: parse bw_accounting correctly...
Nick Mathewson
nickm at seul.org
Wed Nov 10 04:19:56 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv17774/src/or
Modified Files:
hibernate.c
Log Message:
Fix a few bugs in accounting: parse bw_accounting correctly; set end time of continued interval; record used bandwidth on state change.
Index: hibernate.c
===================================================================
RCS file: /home/or/cvsroot/src/or/hibernate.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- hibernate.c 9 Nov 2004 20:04:00 -0000 1.14
+++ hibernate.c 10 Nov 2004 04:19:53 -0000 1.15
@@ -178,6 +178,7 @@
start_of_accounting_period_containing(interval_start_time)) {
log_fn(LOG_INFO, "Continuing accounting interval.");
/* We are in the interval we thought we were in. Do nothing.*/
+ interval_end_time = start_of_accounting_period_after(interval_start_time);
} else {
log_fn(LOG_WARN, "Mismatched accounting interval; starting a fresh one.");
reset_accounting(now);
@@ -228,8 +229,8 @@
static INLINE int
time_to_record_bandwidth_usage(time_t now)
{
- /* Note every 5 minutes */
-#define NOTE_INTERVAL (5*60)
+ /* Note every 60 sec */
+#define NOTE_INTERVAL (60)
/* Or every 20 megabytes */
#define NOTE_BYTES 20*(1024*1024)
static uint64_t last_read_bytes_noted = 0;
@@ -303,6 +304,7 @@
24*60*60 * (unsigned char)digest[0];
}
+/* XXXX009 This should also get called on HUP and shutdown. */
#define BW_ACCOUNTING_VERSION 1
/** Save all our bandwidth tracking information to disk. Return 0 on
* success, -1 on failure*/
@@ -353,7 +355,7 @@
return 0;
}
elts = smartlist_create();
- smartlist_split_string(elts, s, "\n", SPLIT_SKIP_SPACE, SPLIT_IGNORE_BLANK);
+ smartlist_split_string(elts, s, "\n", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK,0);
tor_free(s);
if (smartlist_len(elts)<1 ||
@@ -469,6 +471,7 @@
}
hibernate_state = new_state;
+ record_bandwidth_usage(time(NULL));
}
/** Called when we've been hibernating and our timeout is reached. */
@@ -520,6 +523,8 @@
log_fn(LOG_INFO,"Closing conn type %d", conn->type);
connection_mark_for_close(conn);
}
+
+ record_bandwidth_usage(time(NULL));
}
/** Called when hibernate_end_time has arrived. */
More information about the tor-commits
mailing list