diff options
author | David Goulet <dgoulet@torproject.org> | 2017-10-03 13:58:22 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-10-03 14:43:09 -0400 |
commit | 2e8de0de3b5ae10277cd0fd72e782d2f6aa30c81 (patch) | |
tree | 5ab18dc9862b42c48d7c6dce0dedb5a9590cccba /src/or/scheduler.c | |
parent | 1e7e36da4b6741235e77d97fff8446a6b7ba1300 (diff) | |
download | tor-2e8de0de3b5ae10277cd0fd72e782d2f6aa30c81.tar.gz tor-2e8de0de3b5ae10277cd0fd72e782d2f6aa30c81.zip |
sched: Implement SCHED_BUG()
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/scheduler.c')
-rw-r--r-- | src/or/scheduler.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/or/scheduler.c b/src/or/scheduler.c index 22a9b574ac..c656c80e9c 100644 --- a/src/or/scheduler.c +++ b/src/or/scheduler.c @@ -9,6 +9,9 @@ #define SCHEDULER_KIST_PRIVATE #include "scheduler.h" #include "main.h" +#include "buffers.h" +#define TOR_CHANNEL_INTERNAL_ +#include "channeltls.h" #include <event2/event.h> @@ -667,6 +670,32 @@ scheduler_channel_wants_writes(channel_t *chan) } } +/* Log warn the given channel and extra scheduler context as well. This is + * used by SCHED_BUG() in order to be able to extract as much information as + * we can when we hit a bug. Channel chan can be NULL. */ +void +scheduler_bug_occurred(const channel_t *chan) +{ + char buf[128]; + + if (chan != NULL) { + const size_t outbuf_len = + buf_datalen(TO_CONN(BASE_CHAN_TO_TLS((channel_t *) chan)->conn)->outbuf); + tor_snprintf(buf, sizeof(buf), + "Channel %" PRIu64 " in state %s and scheduler state %d." + " Num cells on cmux: %d. Connection outbuf len: %lu.", + chan->global_identifier, + channel_state_to_string(chan->state), + chan->scheduler_state, circuitmux_num_cells(chan->cmux), + 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"); +} + #ifdef TOR_UNIT_TESTS /* |