Skip to content

tor-proto: Rewrite circuit reactor run_once() loop to use select!.

gabi-250 requested to merge gabi-250/arti:reactor-stuff into main

This branch contains multiple types of changes:

The main changes start at 2eb09f4f, which rewrites the circuit reactor main loop to use select_biased! to poll multiple futures simultaneously.

The new run_once(), like the old, first waits for an initial CtrlMsg::Create. Then, it uses a select_biased! to poll the chan_sender sink and shutdown channel for readiness.

When the channel sink is ready, we poll the control and input channels like before, as well as the new ready_streams Stream (ready_streams is a futures::Stream that replaces the previous send_outbound() function).

Most of the implementation remains unchanged, except the handle_input, handle_cell and handle_control functions no longer send anything on the chan_sender channel. Instead, they may do some (synchronous) processing, and send instructions for the remaining work that needs to be done (for example, for writing the cell to the chan_sender channel). These instructions are handled at the end of run_once(), and are encoded in the RunOnceCmdInner enum.

What this change does not do:

  • the control channel still bypasses congestion control. We could fix this by making the various reactor functions send the RunOnceCmdInner commands to run_once() via a channel (instead of returning them). This would enable the reactor to stop reading the commands (except for handle Sendme, which would be handled separately) if it's blocked on congestion control.
Edited by gabi-250

Merge request reports

Loading