diff options
author | George Kadianakis <desnacked@riseup.net> | 2021-03-10 14:37:36 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2021-03-17 18:22:38 +0200 |
commit | 7740a8b5d4de649e3ba2a0578f789140725974b6 (patch) | |
tree | f6ff31bb373afeb7c3b70fcc12b5b61e7c5635bf /src/feature/stats | |
parent | e688580277cd0223a32bf08603013b59693c713c (diff) | |
download | tor-7740a8b5d4de649e3ba2a0578f789140725974b6.tar.gz tor-7740a8b5d4de649e3ba2a0578f789140725974b6.zip |
Rate-limit counter should increase once per minute.
Diffstat (limited to 'src/feature/stats')
-rw-r--r-- | src/feature/stats/rephist.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index 64bec000df..2c3f362e45 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -280,18 +280,29 @@ STMT_END void rep_hist_note_overload(overload_type_t overload) { + static time_t last_read_counted = 0; + static time_t last_write_counted = 0; + switch (overload) { case OVERLOAD_GENERAL: SET_TO_START_OF_HOUR(overload_stats.overload_general_time); break; - case OVERLOAD_READ: + case OVERLOAD_READ: { SET_TO_START_OF_HOUR(overload_stats.overload_ratelimits_time); - overload_stats.overload_read_count++; + if (approx_time() >= last_read_counted + 60) { /* Count once a minute */ + overload_stats.overload_read_count++; + last_read_counted = approx_time(); + } break; - case OVERLOAD_WRITE: + } + case OVERLOAD_WRITE: { SET_TO_START_OF_HOUR(overload_stats.overload_ratelimits_time); - overload_stats.overload_write_count++; + if (approx_time() >= last_write_counted + 60) { /* Count once a minute */ + overload_stats.overload_write_count++; + last_write_counted = approx_time(); + } break; + } case OVERLOAD_FD_EXHAUSTED: SET_TO_START_OF_HOUR(overload_stats.overload_fd_exhausted_time); overload_stats.overload_fd_exhausted++; |