Tor 0.4.9.0-alpha-dev
Functions
bwhist.h File Reference

Header for feature/stats/bwhist.c. More...

Go to the source code of this file.

Functions

void bwhist_init (void)
 
void bwhist_free_all (void)
 
void bwhist_note_bytes_read (uint64_t num_bytes, time_t when, bool ipv6)
 
void bwhist_note_bytes_written (uint64_t num_bytes, time_t when, bool ipv6)
 
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)
 
int bwhist_bandwidth_assess (void)
 
char * bwhist_get_bandwidth_lines (void)
 
void bwhist_update_state (struct or_state_t *state)
 
int bwhist_load_state (struct or_state_t *state, char **err)
 

Detailed Description

Header for feature/stats/bwhist.c.

Definition in file bwhist.h.

Function Documentation

◆ bwhist_bandwidth_assess()

int bwhist_bandwidth_assess ( void  )

Find the largest sums in the past NUM_SECS_BW_SUM_IS_VALID (roughly) seconds. Find one sum for reading and one for writing. They don't have to be at the same time.

Return the smaller of these sums, divided by NUM_SECS_ROLLING_MEASURE.

Definition at line 241 of file bwhist.c.

Referenced by check_descriptor_bandwidth_changed().

◆ bwhist_free_all()

void bwhist_free_all ( void  )

Definition at line 549 of file bwhist.c.

◆ bwhist_get_bandwidth_lines()

char * bwhist_get_bandwidth_lines ( void  )

Allocate and return lines for representing this server's bandwidth history in its descriptor. We publish these lines in our extra-info descriptor.

Definition at line 332 of file bwhist.c.

◆ bwhist_init()

void bwhist_init ( void  )

Set up structures for bandwidth history, clearing them if they already exist.

Definition at line 139 of file bwhist.c.

Referenced by tor_init().

◆ bwhist_load_state()

int bwhist_load_state ( or_state_t state,
char **  err 
)

Set bandwidth history from the state file we just loaded.

Definition at line 513 of file bwhist.c.

◆ bwhist_note_bytes_read()

void bwhist_note_bytes_read ( uint64_t  num_bytes,
time_t  when,
bool  ipv6 
)

Remember that we wrote num_bytes bytes in second when. (like bwhist_note_bytes_written() above)

Definition at line 183 of file bwhist.c.

Referenced by record_num_bytes_transferred_impl().

◆ bwhist_note_bytes_written()

void bwhist_note_bytes_written ( uint64_t  num_bytes,
time_t  when,
bool  ipv6 
)

Remember that we read num_bytes bytes in second when.

Add num_bytes to the current running total for when.

when can go back to time, but it's safe to ignore calls earlier than the latest when you've heard of.

Definition at line 164 of file bwhist.c.

Referenced by record_num_bytes_transferred_impl().

◆ bwhist_note_dir_bytes_read()

void bwhist_note_dir_bytes_read ( uint64_t  num_bytes,
time_t  when 
)

Remember that we read num_bytes directory bytes in second when. (like bwhist_note_bytes_written() above)

Definition at line 204 of file bwhist.c.

Referenced by record_num_bytes_transferred_impl().

◆ bwhist_note_dir_bytes_written()

void bwhist_note_dir_bytes_written ( uint64_t  num_bytes,
time_t  when 
)

Remember that we wrote num_bytes directory bytes in second when. (like bwhist_note_bytes_written() above)

Definition at line 195 of file bwhist.c.

Referenced by record_num_bytes_transferred_impl().

◆ bwhist_update_state()

void bwhist_update_state ( or_state_t state)

Update state with the newest bandwidth history. Done before writing out a new state file.

Definition at line 411 of file bwhist.c.