[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Rename public bandwidth-history identifiers to start with "bwhist".



commit 2fc8257ac4c3b404f5e41eda8ea98eaaad6c3a5c
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Jul 10 07:54:04 2020 -0400

    Rename public bandwidth-history identifiers to start with "bwhist".
    
    This is an automated commit, generated by this command:
    
    ./scripts/maint/rename_c_identifier.py \
            rep_hist_note_bytes_read bwhist_note_bytes_read \
            rep_hist_note_bytes_written bwhist_note_bytes_written \
            rep_hist_note_dir_bytes_read bwhist_note_dir_bytes_read \
            rep_hist_note_dir_bytes_written bwhist_note_dir_bytes_written \
            rep_hist_get_bandwidth_lines bwhist_get_bandwidth_lines \
            rep_hist_update_state bwhist_update_state \
            rep_hist_load_state bwhist_load_state \
            rep_hist_bandwidth_assess bwhist_bandwidth_assess
---
 src/app/config/statefile.c     |  4 ++--
 src/core/mainloop/connection.c |  8 ++++----
 src/core/or/circuitlist.c      |  2 +-
 src/feature/relay/router.c     |  6 +++---
 src/feature/stats/bwhist.c     | 24 ++++++++++++------------
 src/feature/stats/bwhist.h     | 16 ++++++++--------
 src/test/test_router.c         |  4 ++--
 7 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index 63205007c..4198c8a38 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -324,7 +324,7 @@ or_state_set(or_state_t *new_state)
     tor_free(err);
     ret = -1;
   }
-  if (rep_hist_load_state(global_state, &err)<0) {
+  if (bwhist_load_state(global_state, &err)<0) {
     log_warn(LD_GENERAL,"Unparseable bandwidth history state: %s",err);
     tor_free(err);
     ret = -1;
@@ -523,7 +523,7 @@ or_state_save(time_t now)
    * to avoid redundant writes. */
   (void) subsystems_flush_state(get_state_mgr(), global_state);
   entry_guards_update_state(global_state);
-  rep_hist_update_state(global_state);
+  bwhist_update_state(global_state);
   circuit_build_times_update_state(get_circuit_build_times(), global_state);
 
   if (accounting_is_enabled(get_options()))
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index 7f1b99311..960735fc2 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -3345,9 +3345,9 @@ record_num_bytes_transferred_impl(connection_t *conn,
   /* Count bytes of answering direct and tunneled directory requests */
   if (conn->type == CONN_TYPE_DIR && conn->purpose == DIR_PURPOSE_SERVER) {
     if (num_read > 0)
-      rep_hist_note_dir_bytes_read(num_read, now);
+      bwhist_note_dir_bytes_read(num_read, now);
     if (num_written > 0)
-      rep_hist_note_dir_bytes_written(num_written, now);
+      bwhist_note_dir_bytes_written(num_written, now);
   }
 
   /* Linked connections and internal IPs aren't counted for statistics or
@@ -3367,10 +3367,10 @@ record_num_bytes_transferred_impl(connection_t *conn,
                                 num_written, now);
 
   if (num_read > 0) {
-    rep_hist_note_bytes_read(num_read, now);
+    bwhist_note_bytes_read(num_read, now);
   }
   if (num_written > 0) {
-    rep_hist_note_bytes_written(num_written, now);
+    bwhist_note_bytes_written(num_written, now);
   }
   if (conn->type == CONN_TYPE_EXIT)
     rep_hist_note_exit_bytes(conn->port, num_written, num_read);
diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c
index a6949d943..f0f182e5d 100644
--- a/src/core/or/circuitlist.c
+++ b/src/core/or/circuitlist.c
@@ -2174,7 +2174,7 @@ circuit_synchronize_written_or_bandwidth(const circuit_t *c,
   /* Report the missing bytes as written, to avoid asymmetry.
    * We must use time() for consistency with rephist, even though on
    * some very old rare platforms, approx_time() may be faster. */
-  rep_hist_note_bytes_written(written_sync, time(NULL));
+  bwhist_note_bytes_written(written_sync, time(NULL));
 }
 
 /** Mark <b>circ</b> to be closed next time we call
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index a55b30067..b63950ea1 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -2099,7 +2099,7 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out))
   ri->bandwidthburst = relay_get_effective_bwburst(options);
 
   /* Report bandwidth, unless we're hibernating or shutting down */
-  ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();
+  ri->bandwidthcapacity = hibernating ? 0 : bwhist_bandwidth_assess();
 
   if (dns_seems_to_be_broken() || has_dns_init_failed()) {
     /* DNS is screwed up; don't claim to be an exit. */
@@ -2545,7 +2545,7 @@ check_descriptor_bandwidth_changed(time_t now)
 
   /* Consider ourselves to have zero bandwidth if we're hibernating or
    * shutting down. */
-  cur = hibernating ? 0 : rep_hist_bandwidth_assess();
+  cur = hibernating ? 0 : bwhist_bandwidth_assess();
 
   if ((prev != cur && (!prev || !cur)) ||
       cur > (prev * BANDWIDTH_CHANGE_FACTOR) ||
@@ -3209,7 +3209,7 @@ extrainfo_dump_to_string_stats_helper(smartlist_t *chunks,
     log_info(LD_GENERAL, "Adding stats to extra-info descriptor.");
     /* Bandwidth usage stats don't have their own option */
     {
-      contents = rep_hist_get_bandwidth_lines();
+      contents = bwhist_get_bandwidth_lines();
       smartlist_add(chunks, contents);
     }
     /* geoip hashes aren't useful unless we are publishing other stats */
diff --git a/src/feature/stats/bwhist.c b/src/feature/stats/bwhist.c
index a3b971a25..2bc533e66 100644
--- a/src/feature/stats/bwhist.c
+++ b/src/feature/stats/bwhist.c
@@ -197,7 +197,7 @@ bwhist_init(void)
  * earlier than the latest <b>when</b> you've heard of.
  */
 void
-rep_hist_note_bytes_written(uint64_t num_bytes, time_t when)
+bwhist_note_bytes_written(uint64_t num_bytes, time_t when)
 {
 /* Maybe a circular array for recent seconds, and step to a new point
  * every time a new second shows up. Or simpler is to just to have
@@ -205,35 +205,35 @@ rep_hist_note_bytes_written(uint64_t num_bytes, time_t when)
  */
 /* When a new second has rolled over, compute the sum of the bytes we've
  * seen over when-1 to when-1-NUM_SECS_ROLLING_MEASURE, and stick it
- * somewhere. See rep_hist_bandwidth_assess() below.
+ * somewhere. See bwhist_bandwidth_assess() below.
  */
   add_obs(write_array, when, num_bytes);
 }
 
 /** Remember that we wrote <b>num_bytes</b> bytes in second <b>when</b>.
- * (like rep_hist_note_bytes_written() above)
+ * (like bwhist_note_bytes_written() above)
  */
 void
-rep_hist_note_bytes_read(uint64_t num_bytes, time_t when)
+bwhist_note_bytes_read(uint64_t num_bytes, time_t when)
 {
 /* if we're smart, we can make this func and the one above share code */
   add_obs(read_array, when, num_bytes);
 }
 
 /** Remember that we wrote <b>num_bytes</b> directory bytes in second
- * <b>when</b>. (like rep_hist_note_bytes_written() above)
+ * <b>when</b>. (like bwhist_note_bytes_written() above)
  */
 void
-rep_hist_note_dir_bytes_written(uint64_t num_bytes, time_t when)
+bwhist_note_dir_bytes_written(uint64_t num_bytes, time_t when)
 {
   add_obs(dir_write_array, when, num_bytes);
 }
 
 /** Remember that we read <b>num_bytes</b> directory bytes in second
- * <b>when</b>. (like rep_hist_note_bytes_written() above)
+ * <b>when</b>. (like bwhist_note_bytes_written() above)
  */
 void
-rep_hist_note_dir_bytes_read(uint64_t num_bytes, time_t when)
+bwhist_note_dir_bytes_read(uint64_t num_bytes, time_t when)
 {
   add_obs(dir_read_array, when, num_bytes);
 }
@@ -262,7 +262,7 @@ find_largest_max(bw_array_t *b)
  * Return the smaller of these sums, divided by NUM_SECS_ROLLING_MEASURE.
  */
 MOCK_IMPL(int,
-rep_hist_bandwidth_assess,(void))
+bwhist_bandwidth_assess,(void))
 {
   uint64_t w,r;
   r = find_largest_max(read_array);
@@ -329,7 +329,7 @@ rep_hist_fill_bandwidth_history(char *buf, size_t len, const bw_array_t *b)
  * descriptor.
  */
 char *
-rep_hist_get_bandwidth_lines(void)
+bwhist_get_bandwidth_lines(void)
 {
   char *buf, *cp;
   char t[ISO_TIME_LEN+1];
@@ -446,7 +446,7 @@ rep_hist_update_bwhist_state_section(or_state_t *state,
 /** Update <b>state</b> with the newest bandwidth history. Done before
  * writing out a new state file. */
 void
-rep_hist_update_state(or_state_t *state)
+bwhist_update_state(or_state_t *state)
 {
 #define UPDATE(arrname,st) \
   rep_hist_update_bwhist_state_section(state,\
@@ -546,7 +546,7 @@ rep_hist_load_bwhist_state_section(bw_array_t *b,
 
 /** Set bandwidth history from the state file we just loaded. */
 int
-rep_hist_load_state(or_state_t *state, char **err)
+bwhist_load_state(or_state_t *state, char **err)
 {
   int all_ok = 1;
 
diff --git a/src/feature/stats/bwhist.h b/src/feature/stats/bwhist.h
index afe0d9f4e..17d2a8394 100644
--- a/src/feature/stats/bwhist.h
+++ b/src/feature/stats/bwhist.h
@@ -15,16 +15,16 @@
 void bwhist_init(void);
 void bwhist_free_all(void);
 
-void rep_hist_note_bytes_read(uint64_t num_bytes, time_t when);
-void rep_hist_note_bytes_written(uint64_t num_bytes, time_t when);
-void rep_hist_note_dir_bytes_read(uint64_t num_bytes, time_t when);
-void rep_hist_note_dir_bytes_written(uint64_t num_bytes, time_t when);
+void bwhist_note_bytes_read(uint64_t num_bytes, time_t when);
+void bwhist_note_bytes_written(uint64_t num_bytes, time_t when);
+void bwhist_note_dir_bytes_read(uint64_t num_bytes, time_t when);
+void bwhist_note_dir_bytes_written(uint64_t num_bytes, time_t when);
 
-MOCK_DECL(int, rep_hist_bandwidth_assess, (void));
-char *rep_hist_get_bandwidth_lines(void);
+MOCK_DECL(int, bwhist_bandwidth_assess, (void));
+char *bwhist_get_bandwidth_lines(void);
 struct or_state_t;
-void rep_hist_update_state(struct or_state_t *state);
-int rep_hist_load_state(struct or_state_t *state, char **err);
+void bwhist_update_state(struct or_state_t *state);
+int bwhist_load_state(struct or_state_t *state, char **err);
 
 #ifdef BWHIST_PRIVATE
 typedef struct bw_array_t bw_array_t;
diff --git a/src/test/test_router.c b/src/test/test_router.c
index 9822729f5..010289397 100644
--- a/src/test/test_router.c
+++ b/src/test/test_router.c
@@ -226,13 +226,13 @@ test_router_check_descriptor_bandwidth_changed(void *arg)
 
   /* When uptime is less than 24h and bandwidthcapacity does not change
    * Uptime: 10800, last_changed: x, Previous bw: 10000, Current bw: 20001 */
-  MOCK(rep_hist_bandwidth_assess, mock_rep_hist_bandwidth_assess);
+  MOCK(bwhist_bandwidth_assess, mock_rep_hist_bandwidth_assess);
   setup_full_capture_of_logs(LOG_INFO);
   check_descriptor_bandwidth_changed(time(NULL) + 6*60*60 + 1);
   expect_log_msg_containing(
      "Measured bandwidth has changed; rebuilding descriptor.");
   UNMOCK(get_uptime);
-  UNMOCK(rep_hist_bandwidth_assess);
+  UNMOCK(bwhist_bandwidth_assess);
   teardown_capture_of_logs();
 
   /* When uptime is more than 24h */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits