Tor  0.4.6.0-alpha-dev
Functions
connstats.h File Reference

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

Go to the source code of this file.

Functions

void conn_stats_init (time_t now)
 
void conn_stats_note_or_conn_bytes (uint64_t conn_id, size_t num_read, size_t num_written, time_t when, bool is_ipv6)
 
void conn_stats_reset (time_t now)
 
char * conn_stats_format (time_t now)
 
time_t conn_stats_save (time_t now)
 
void conn_stats_terminate (void)
 
void conn_stats_free_all (void)
 

Detailed Description

Header for feature/stats/connstats.c.

Definition in file connstats.h.

Function Documentation

◆ conn_stats_format()

char* conn_stats_format ( time_t  now)

Return a newly allocated string containing the connection statistics until now, or NULL if we're not collecting conn stats. Caller must ensure start_of_conn_stats_interval is in the past.

Definition at line 224 of file connstats.c.

◆ conn_stats_free_all()

void conn_stats_free_all ( void  )

Release all storage held in connstats.c

Definition at line 112 of file connstats.c.

Referenced by conn_stats_reset().

◆ conn_stats_init()

void conn_stats_init ( time_t  now)

Initialize connection stats.

Definition at line 30 of file connstats.c.

◆ conn_stats_note_or_conn_bytes()

void conn_stats_note_or_conn_bytes ( uint64_t  conn_id,
size_t  num_read,
size_t  num_written,
time_t  when,
bool  is_ipv6 
)

We read num_read bytes and wrote num_written from/to OR connection conn_id in second when. If this is the first observation in a new interval, sum up the last observations. Add bytes for this connection.

Definition at line 185 of file connstats.c.

Referenced by record_num_bytes_transferred_impl().

◆ conn_stats_reset()

void conn_stats_reset ( time_t  now)

Reset counters for conn statistics.

Definition at line 125 of file connstats.c.

Referenced by conn_stats_terminate().

◆ conn_stats_save()

time_t conn_stats_save ( time_t  now)

If 24 hours have passed since the beginning of the current conn stats period, write conn stats to $DATADIR/stats/conn-stats (possibly overwriting an existing file) and reset counters. Return when we would next want to write conn stats or 0 if we never want to write.

Definition at line 260 of file connstats.c.

◆ conn_stats_terminate()

void conn_stats_terminate ( void  )

Stop collecting connection stats in a way that we can re-start doing so in conn_stats_init().

Definition at line 136 of file connstats.c.