[tor-bugs] #24531 [Core Tor/Tor]: sched: Add function to change scheduler state and always use it

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Dec 6 16:34:58 UTC 2017


#24531: sched: Add function to change scheduler state and always use it
-----------------------------+------------------------------------
 Reporter:  pastly           |          Owner:  (none)
     Type:  defect           |         Status:  new
 Priority:  Medium           |      Milestone:  Tor: 0.3.3.x-final
Component:  Core Tor/Tor     |        Version:
 Severity:  Normal           |     Resolution:
 Keywords:  tor-sched, easy  |  Actual Points:
Parent ID:                   |         Points:
 Reviewer:                   |        Sponsor:
-----------------------------+------------------------------------

Comment (by pastly):

 Replying to [comment:2 aruna1234]:
 > Could you give more information on this one?

 In many places in the scheduling code we do (IDLE just used as an example)

 {{{
 chan->scheduler_state = SCHED_CHAN_IDLE;
 }}}

 I'm proposing we replace all these assignments to a channel's
 `scheduler_state` with a function that does it for us and logs the old and
 new state. It would most likely need to be defined in the "Private
 scheduler functions" section of `scheduler.h` in order to be reachable
 from all the scheduler source files.

 In slightly better pseudocode, I propose the function looks like

 {{{
 scheduler_set_channel_state(chan, new_state)
 {
   log_debug(LD_SCHED, "chan %d changed from scheduler state %d to %d",
       chan->global_id, chan->scheduler_state, new_state);
   chan->scheduler_state = new_state;
 }
 }}}

 Ideally we would log "from state IDLE to WAITING_FOR_CELLS", which would
 call for a helper function if it doesn't already exist. And the int type
 on the channel's global ID needs to be correct, etc. etc.

 The bonus points are for also logging the channel information that's
 logged in `scheduler_bug_occurred` like # of cmux cells and connection
 outbuf len.

 (Note: bonus points aren't real, they just make dgoulet/pastly happy)

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24531#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list