summaryrefslogtreecommitdiff
path: root/src/or/or.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-07 20:11:30 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-07 20:11:30 +0000
commit7c79495137bcd3989428d65b184038aa71fbae70 (patch)
treea18217ed1dfeb55a8ba045772364d08837f20fbb /src/or/or.h
parentc304a10fd3ec7943734d47c2e95fcd1b75bf526d (diff)
downloadtor-7c79495137bcd3989428d65b184038aa71fbae70.tar.gz
tor-7c79495137bcd3989428d65b184038aa71fbae70.zip
r11468@Kushana: nickm | 2006-12-07 14:56:57 -0500
Revise logic used to flush state to disk. Now, we try to batch non-urgent changes so that we do not do too many writes, and we save very-non-urgent changes every once in a rare while, and we never save more than once per second. svn:r9047
Diffstat (limited to 'src/or/or.h')
-rw-r--r--src/or/or.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/or/or.h b/src/or/or.h
index 9f25dfd59a..053c5a499d 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1655,19 +1655,30 @@ typedef struct {
/** Persistent state for an onion router, as saved to disk. */
typedef struct {
uint32_t _magic;
- /** True iff this state has been changed since it was last read/written
- * to the disk. */
- int dirty;
+ /** The time at which we next plan to write the state to the disk. Equal to
+ * TIME_MAX if there are no saveable changes, 0 if there are changes that
+ * should be saved right away. */
+ time_t next_write;
+ /** When was the state last written to disk? */
time_t LastWritten;
+
+ /** Fields for */
time_t AccountingIntervalStart;
uint64_t AccountingBytesReadInInterval;
uint64_t AccountingBytesWrittenInInterval;
int AccountingSecondsActive;
uint64_t AccountingExpectedUsage;
+ /** A list of Entry Guard-related configuration lines. */
config_line_t *EntryGuards;
+ /** These fields hold information on the history of bandwidth usage for
+ * servers. The "Ends" fields hold the time when we last updated the
+ * bandwidth usage. The "Interval" fields hold the granularity, in seconds,
+ * of the entries of Values. The "Values" lists hold decimal string
+ * representations of the number of bytes read or written in each
+ * interval. */
time_t BWHistoryReadEnds;
int BWHistoryReadInterval;
smartlist_t *BWHistoryReadValues;
@@ -1675,11 +1686,24 @@ typedef struct {
int BWHistoryWriteInterval;
smartlist_t *BWHistoryWriteValues;
+ /** What version of Tor write this state file? */
char *TorVersion;
+ /** holds any unrecognized values we found in the state file, in the order
+ * in which we found them. */
config_line_t *ExtraLines;
} or_state_t;
+static void or_state_mark_dirty(or_state_t *state, time_t when);
+/** Change the next_write time of <b>state</b> to <b>when</b>, unless the
+ * state is already scheduled to be written to disk earlier than <b>when</b>.
+ */
+static INLINE void or_state_mark_dirty(or_state_t *state, time_t when)
+{
+ if (state->next_write > when)
+ state->next_write = when;
+}
+
#define MAX_SOCKS_REPLY_LEN 1024
#define MAX_SOCKS_ADDR_LEN 256
#define SOCKS_COMMAND_CONNECT 0x01
@@ -1897,7 +1921,7 @@ const char *get_torrc_fname(void);
or_state_t *get_or_state(void);
int or_state_load(void);
-int or_state_save(void);
+int or_state_save(time_t now);
int config_getinfo_helper(const char *question, char **answer);