[tor-commits] [tor/master] Move or_state_mark_dirty into statefile.c

nickm at torproject.org nickm at torproject.org
Mon Apr 30 20:48:59 UTC 2018


commit 9f8b60d74c91f4028b68ea8345a5562768acc81e
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Apr 27 10:05:53 2018 -0400

    Move or_state_mark_dirty into statefile.c
    
    Previously it was an inline function in or.h
---
 src/or/or.h        |  9 ---------
 src/or/rephist.c   |  2 +-
 src/or/statefile.c | 12 +++++++++++-
 src/or/statefile.h |  1 +
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/or/or.h b/src/or/or.h
index e27f25197..06262e430 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -4745,15 +4745,6 @@ typedef struct {
   time_t LastRotatedOnionKey;
 } or_state_t;
 
-/** 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_NO_AUTH 0x00
diff --git a/src/or/rephist.c b/src/or/rephist.c
index ac3e9f502..bac2efb1f 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -85,8 +85,8 @@
 #include "routerlist.h"
 #include "ht.h"
 #include "channelpadding.h"
-
 #include "connection_or.h"
+#include "statefile.h"
 
 static void bw_arrays_init(void);
 static void predicted_ports_alloc(void);
diff --git a/src/or/statefile.c b/src/or/statefile.c
index cc114f0a2..26a631ced 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -472,7 +472,7 @@ or_state_save(time_t now)
 
   tor_assert(global_state);
 
-  if (global_state->next_write > now)
+  if (global_state->next_write >= now)
     return 0;
 
   /* Call everything else that might dirty the state even more, in order
@@ -680,6 +680,16 @@ save_transport_to_state(const char *transport,
   tor_free(transport_addrport);
 }
 
+/** 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>.
+ */
+void
+or_state_mark_dirty(or_state_t *state, time_t when)
+{
+  if (state->next_write > when)
+    state->next_write = when;
+}
+
 STATIC void
 or_state_free_(or_state_t *state)
 {
diff --git a/src/or/statefile.h b/src/or/statefile.h
index b4cc4d1dc..5aa2ca932 100644
--- a/src/or/statefile.h
+++ b/src/or/statefile.h
@@ -17,6 +17,7 @@ char *get_stored_bindaddr_for_server_transport(const char *transport);
 int or_state_load(void);
 int or_state_loaded(void);
 void or_state_free_all(void);
+void or_state_mark_dirty(or_state_t *state, time_t when);
 
 #ifdef STATEFILE_PRIVATE
 STATIC config_line_t *get_transport_in_state_by_name(const char *transport);





More information about the tor-commits mailing list