diff options
author | David Goulet <dgoulet@torproject.org> | 2017-10-26 14:44:44 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-11-02 10:30:33 -0400 |
commit | 6dc591a024e4dde8f4beafc7d42bdaeac996cca4 (patch) | |
tree | a882efc547e692832269aede8725e5f3cc10cc56 | |
parent | 52050bb2c6b498c05c7ec54947deff5f662db34e (diff) | |
download | tor-6dc591a024e4dde8f4beafc7d42bdaeac996cca4.tar.gz tor-6dc591a024e4dde8f4beafc7d42bdaeac996cca4.zip |
sched: Rate limit scheduler_bug_occurred()
Just in case we end up hitting a SCHED_BUG() multiple times, rate limit the
log warning.
Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r-- | src/or/scheduler.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/or/scheduler.c b/src/or/scheduler.c index 67911ff81e..97b6d40b1e 100644 --- a/src/or/scheduler.c +++ b/src/or/scheduler.c @@ -690,10 +690,21 @@ scheduler_bug_occurred(const channel_t *chan) outbuf_len); } - log_warn(LD_BUG, "%s Num pending channels: %d. Channel in pending list: %s", - (chan != NULL) ? buf : "No channel in bug context.", - smartlist_len(channels_pending), - (smartlist_pos(channels_pending, chan) == -1) ? "no" : "yes"); + { + char *msg; + /* Rate limit every 60 seconds. If we start seeing this every 60 sec, we + * know something is stuck/wrong. It *should* be loud but not too much. */ + static ratelim_t rlimit = RATELIM_INIT(60); + if ((msg = rate_limit_log(&rlimit, approx_time()))) { + log_warn(LD_BUG, "%s Num pending channels: %d. " + "Channel in pending list: %s.%s", + (chan != NULL) ? buf : "No channel in bug context.", + smartlist_len(channels_pending), + (smartlist_pos(channels_pending, chan) == -1) ? "no" : "yes", + msg); + tor_free(msg); + } + } } #ifdef TOR_UNIT_TESTS |