diff options
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index 2844c4d74e..dc86fad1d0 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -88,6 +88,11 @@ static void bw_arrays_init(void); static void predicted_ports_init(void); +typedef struct bw_array_t bw_array_t; +STATIC uint64_t find_largest_max(bw_array_t *b); +STATIC void commit_max(bw_array_t *b); +STATIC void advance_obs(bw_array_t *b); + /** Total number of bytes currently allocated in fields used by rephist.c. */ uint64_t rephist_total_alloc=0; /** Number of or_history_t objects currently allocated. */ @@ -1206,7 +1211,7 @@ rep_hist_load_mtbf_data(time_t now) /** Structure to track bandwidth use, and remember the maxima for a given * time period. */ -typedef struct bw_array_t { +struct bw_array_t { /** Observation array: Total number of bytes transferred in each of the last * NUM_SECS_ROLLING_MEASURE seconds. This is used as a circular array. */ uint64_t obs[NUM_SECS_ROLLING_MEASURE]; @@ -1233,10 +1238,10 @@ typedef struct bw_array_t { /** Circular array of the total bandwidth usage for the last NUM_TOTALS * periods */ uint64_t totals[NUM_TOTALS]; -} bw_array_t; +}; /** Shift the current period of b forward by one. */ -static void +STATIC void commit_max(bw_array_t *b) { /* Store total from current period. */ @@ -1256,7 +1261,7 @@ commit_max(bw_array_t *b) } /** Shift the current observation time of <b>b</b> forward by one second. */ -static inline void +STATIC void advance_obs(bw_array_t *b) { int nextidx; @@ -1331,7 +1336,7 @@ bw_array_free(bw_array_t *b) /** Recent history of bandwidth observations for read operations. */ static bw_array_t *read_array = NULL; /** Recent history of bandwidth observations for write operations. */ -static bw_array_t *write_array = NULL; +STATIC bw_array_t *write_array = NULL; /** Recent history of bandwidth observations for read operations for the directory protocol. */ static bw_array_t *dir_read_array = NULL; @@ -1363,7 +1368,7 @@ bw_arrays_init(void) * earlier than the latest <b>when</b> you've heard of. */ void -rep_hist_note_bytes_written(size_t num_bytes, time_t when) +rep_hist_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 @@ -1380,7 +1385,7 @@ rep_hist_note_bytes_written(size_t num_bytes, time_t when) * (like rep_hist_note_bytes_written() above) */ void -rep_hist_note_bytes_read(size_t num_bytes, time_t when) +rep_hist_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); @@ -1390,7 +1395,7 @@ rep_hist_note_bytes_read(size_t num_bytes, time_t when) * <b>when</b>. (like rep_hist_note_bytes_written() above) */ void -rep_hist_note_dir_bytes_written(size_t num_bytes, time_t when) +rep_hist_note_dir_bytes_written(uint64_t num_bytes, time_t when) { add_obs(dir_write_array, when, num_bytes); } @@ -1399,7 +1404,7 @@ rep_hist_note_dir_bytes_written(size_t num_bytes, time_t when) * <b>when</b>. (like rep_hist_note_bytes_written() above) */ void -rep_hist_note_dir_bytes_read(size_t num_bytes, time_t when) +rep_hist_note_dir_bytes_read(uint64_t num_bytes, time_t when) { add_obs(dir_read_array, when, num_bytes); } @@ -1408,7 +1413,7 @@ rep_hist_note_dir_bytes_read(size_t num_bytes, time_t when) * most bandwidth used in any NUM_SECS_ROLLING_MEASURE period for the last * NUM_SECS_BW_SUM_IS_VALID seconds.) */ -static uint64_t +STATIC uint64_t find_largest_max(bw_array_t *b) { int i; @@ -3292,4 +3297,3 @@ rep_hist_free_all(void) tor_assert_nonfatal(rephist_total_alloc == 0); tor_assert_nonfatal_once(rephist_total_num == 0); } - |