diff options
author | Andrea Shepard <andrea@torproject.org> | 2013-08-25 08:45:07 -0700 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2014-09-30 22:48:24 -0700 |
commit | d438cf1ec9d5de08b8a8fffd7c38b66134fd337c (patch) | |
tree | 0ce78e25fde753880ff5bf092c1599d982d0c8a5 /src/or/channel.c | |
parent | 1987157d0c1e9acb0b88156e7104fbc8a11c5932 (diff) | |
download | tor-d438cf1ec9d5de08b8a8fffd7c38b66134fd337c.tar.gz tor-d438cf1ec9d5de08b8a8fffd7c38b66134fd337c.zip |
Implement scheduler mechanism to track lists of channels wanting cells or writes; doesn't actually drive the cell flow from it yet
Diffstat (limited to 'src/or/channel.c')
-rw-r--r-- | src/or/channel.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/channel.c b/src/or/channel.c index c8c92633b1..da2493a758 100644 --- a/src/or/channel.c +++ b/src/or/channel.c @@ -29,6 +29,7 @@ #include "rephist.h" #include "router.h" #include "routerlist.h" +#include "scheduler.h" /* Cell queue structure */ @@ -788,6 +789,9 @@ channel_free(channel_t *chan) "Freeing channel " U64_FORMAT " at %p", U64_PRINTF_ARG(chan->global_identifier), chan); + /* Get this one out of the scheduler */ + scheduler_release_channel(chan); + /* * Get rid of cmux policy before we do anything, so cmux policies don't * see channels in weird half-freed states. @@ -863,6 +867,9 @@ channel_force_free(channel_t *chan) "Force-freeing channel " U64_FORMAT " at %p", U64_PRINTF_ARG(chan->global_identifier), chan); + /* Get this one out of the scheduler */ + scheduler_release_channel(chan); + /* * Get rid of cmux policy before we do anything, so cmux policies don't * see channels in weird half-freed states. @@ -1941,6 +1948,18 @@ channel_change_state(channel_t *chan, channel_state_t to_state) } } + /* + * If we're going to a closed/closing state, we don't need scheduling any + * more; in CHANNEL_STATE_MAINT we can't accept writes. + */ + if (to_state == CHANNEL_STATE_CLOSING || + to_state == CHANNEL_STATE_CLOSED || + to_state == CHANNEL_STATE_ERROR) { + scheduler_release_channel(chan); + } else if (to_state == CHANNEL_STATE_MAINT) { + scheduler_channel_doesnt_want_writes(chan); + } + /* Tell circuits if we opened and stuff */ if (to_state == CHANNEL_STATE_OPEN) { channel_do_open_actions(chan); |