mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Fix cosmetic issues around scheduler_set_channel_state
Whitespace issues Line length Unused variable
This commit is contained in:
parent
ad5cfa3039
commit
5e7fdb8b3f
2 changed files with 16 additions and 15 deletions
|
@ -361,12 +361,15 @@ set_scheduler(void)
|
||||||
*
|
*
|
||||||
* Functions that can only be accessed from scheduler*.c
|
* Functions that can only be accessed from scheduler*.c
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/* Function to log and change all the old and new states*/
|
|
||||||
|
|
||||||
void scheduler_set_channel_state(channel_t *chan,int new_state){
|
/** Helper that logs channel scheduler_state changes. Use this instead of
|
||||||
log_debug(LD_SCHED, "chan %s changed from scheduler state %d to %d",chan->global_identifier, chan->scheduler_state, new_state);
|
* setting scheduler_state directly. */
|
||||||
|
void scheduler_set_channel_state(channel_t *chan, int new_state){
|
||||||
|
log_debug(LD_SCHED, "chan %s changed from scheduler state %d to %d",
|
||||||
|
chan->global_identifier, chan->scheduler_state, new_state);
|
||||||
chan->scheduler_state = new_state;
|
chan->scheduler_state = new_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the pending channel list. */
|
/** Return the pending channel list. */
|
||||||
smartlist_t *
|
smartlist_t *
|
||||||
get_channels_pending(void)
|
get_channels_pending(void)
|
||||||
|
@ -494,7 +497,7 @@ scheduler_channel_doesnt_want_writes,(channel_t *chan))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it's already in pending, we can put it in waiting_to_write */
|
/* If it's already in pending, we can put it in waiting_to_write */
|
||||||
if (chan->scheduler_state == SCHED_CHAN_PENDING){
|
if (chan->scheduler_state == SCHED_CHAN_PENDING) {
|
||||||
/*
|
/*
|
||||||
* It's in channels_pending, so it shouldn't be in any of
|
* It's in channels_pending, so it shouldn't be in any of
|
||||||
* the other lists. It can't write any more, so it goes to
|
* the other lists. It can't write any more, so it goes to
|
||||||
|
@ -504,7 +507,7 @@ scheduler_channel_doesnt_want_writes,(channel_t *chan))
|
||||||
scheduler_compare_channels,
|
scheduler_compare_channels,
|
||||||
offsetof(channel_t, sched_heap_idx),
|
offsetof(channel_t, sched_heap_idx),
|
||||||
chan);
|
chan);
|
||||||
scheduler_set_channel_state(chan,SCHED_CHAN_WAITING_TO_WRITE);
|
scheduler_set_channel_state(chan, SCHED_CHAN_WAITING_TO_WRITE);
|
||||||
log_debug(LD_SCHED,
|
log_debug(LD_SCHED,
|
||||||
"Channel " U64_FORMAT " at %p went from pending "
|
"Channel " U64_FORMAT " at %p went from pending "
|
||||||
"to waiting_to_write",
|
"to waiting_to_write",
|
||||||
|
@ -515,8 +518,8 @@ scheduler_channel_doesnt_want_writes,(channel_t *chan))
|
||||||
* either not in any of the lists (nothing to do) or it's already in
|
* either not in any of the lists (nothing to do) or it's already in
|
||||||
* waiting_for_cells (remove it, can't write any more).
|
* waiting_for_cells (remove it, can't write any more).
|
||||||
*/
|
*/
|
||||||
if (chan->scheduler_state == SCHED_CHAN_WAITING_FOR_CELLS){
|
if (chan->scheduler_state == SCHED_CHAN_WAITING_FOR_CELLS) {
|
||||||
scheduler_set_channel_state(chan,SCHED_CHAN_IDLE);
|
scheduler_set_channel_state(chan, SCHED_CHAN_IDLE);
|
||||||
log_debug(LD_SCHED,
|
log_debug(LD_SCHED,
|
||||||
"Channel " U64_FORMAT " at %p left waiting_for_cells",
|
"Channel " U64_FORMAT " at %p left waiting_for_cells",
|
||||||
U64_PRINTF_ARG(chan->global_identifier), chan);
|
U64_PRINTF_ARG(chan->global_identifier), chan);
|
||||||
|
@ -536,13 +539,13 @@ scheduler_channel_has_waiting_cells,(channel_t *chan))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First, check if it's also writeable */
|
/* First, check if it's also writeable */
|
||||||
if (chan->scheduler_state == SCHED_CHAN_WAITING_FOR_CELLS){
|
if (chan->scheduler_state == SCHED_CHAN_WAITING_FOR_CELLS) {
|
||||||
/*
|
/*
|
||||||
* It's in channels_waiting_for_cells, so it shouldn't be in any of
|
* It's in channels_waiting_for_cells, so it shouldn't be in any of
|
||||||
* the other lists. It has waiting cells now, so it goes to
|
* the other lists. It has waiting cells now, so it goes to
|
||||||
* channels_pending.
|
* channels_pending.
|
||||||
*/
|
*/
|
||||||
scheduler_set_channel_state(chan,SCHED_CHAN_PENDING);
|
scheduler_set_channel_state(chan, SCHED_CHAN_PENDING);
|
||||||
smartlist_pqueue_add(channels_pending,
|
smartlist_pqueue_add(channels_pending,
|
||||||
scheduler_compare_channels,
|
scheduler_compare_channels,
|
||||||
offsetof(channel_t, sched_heap_idx),
|
offsetof(channel_t, sched_heap_idx),
|
||||||
|
@ -561,7 +564,7 @@ scheduler_channel_has_waiting_cells,(channel_t *chan))
|
||||||
* or it's already in waiting_to_write or pending (we do nothing)
|
* or it's already in waiting_to_write or pending (we do nothing)
|
||||||
*/
|
*/
|
||||||
if (!(chan->scheduler_state == SCHED_CHAN_WAITING_TO_WRITE ||
|
if (!(chan->scheduler_state == SCHED_CHAN_WAITING_TO_WRITE ||
|
||||||
chan->scheduler_state== SCHED_CHAN_PENDING)) {
|
chan->scheduler_state == SCHED_CHAN_PENDING)) {
|
||||||
scheduler_set_channel_state(chan, SCHED_CHAN_WAITING_TO_WRITE);
|
scheduler_set_channel_state(chan, SCHED_CHAN_WAITING_TO_WRITE);
|
||||||
log_debug(LD_SCHED,
|
log_debug(LD_SCHED,
|
||||||
"Channel " U64_FORMAT " at %p entered waiting_to_write",
|
"Channel " U64_FORMAT " at %p entered waiting_to_write",
|
||||||
|
@ -648,7 +651,7 @@ scheduler_release_channel,(channel_t *chan))
|
||||||
if (the_scheduler->on_channel_free) {
|
if (the_scheduler->on_channel_free) {
|
||||||
the_scheduler->on_channel_free(chan);
|
the_scheduler->on_channel_free(chan);
|
||||||
}
|
}
|
||||||
scheduler_set_channel_state(chan,SCHED_CHAN_IDLE);
|
scheduler_set_channel_state(chan, SCHED_CHAN_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mark a channel as ready to accept writes */
|
/** Mark a channel as ready to accept writes */
|
||||||
|
@ -674,7 +677,7 @@ scheduler_channel_wants_writes(channel_t *chan)
|
||||||
scheduler_compare_channels,
|
scheduler_compare_channels,
|
||||||
offsetof(channel_t, sched_heap_idx),
|
offsetof(channel_t, sched_heap_idx),
|
||||||
chan);
|
chan);
|
||||||
scheduler_set_channel_state(chan,SCHED_CHAN_PENDING);
|
scheduler_set_channel_state(chan, SCHED_CHAN_PENDING);
|
||||||
log_debug(LD_SCHED,
|
log_debug(LD_SCHED,
|
||||||
"Channel " U64_FORMAT " at %p went from waiting_to_write "
|
"Channel " U64_FORMAT " at %p went from waiting_to_write "
|
||||||
"to pending",
|
"to pending",
|
||||||
|
@ -705,7 +708,6 @@ scheduler_bug_occurred(const channel_t *chan)
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
if (chan != NULL) {
|
if (chan != NULL) {
|
||||||
int new_state=0;
|
|
||||||
const size_t outbuf_len =
|
const size_t outbuf_len =
|
||||||
buf_datalen(TO_CONN(BASE_CHAN_TO_TLS((channel_t *) chan)->conn)->outbuf);
|
buf_datalen(TO_CONN(BASE_CHAN_TO_TLS((channel_t *) chan)->conn)->outbuf);
|
||||||
tor_snprintf(buf, sizeof(buf),
|
tor_snprintf(buf, sizeof(buf),
|
||||||
|
|
|
@ -143,9 +143,8 @@ MOCK_DECL(void, scheduler_channel_has_waiting_cells, (channel_t *chan));
|
||||||
/*********************************
|
/*********************************
|
||||||
* Defined in scheduler.c
|
* Defined in scheduler.c
|
||||||
*********************************/
|
*********************************/
|
||||||
/* Function to log and change all the old and new states*/
|
|
||||||
|
|
||||||
void scheduler_set_channel_state(channel_t *chan,int new_state);
|
void scheduler_set_channel_state(channel_t *chan, int new_state);
|
||||||
|
|
||||||
/* Triggers a BUG() and extra information with chan if available. */
|
/* Triggers a BUG() and extra information with chan if available. */
|
||||||
#define SCHED_BUG(cond, chan) \
|
#define SCHED_BUG(cond, chan) \
|
||||||
|
|
Loading…
Add table
Reference in a new issue