summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/circuit
Commit message (Collapse)AuthorAgeFilesLines
* Fix typosDimitris Apostolou2024-09-031-1/+1
|
* Move stream_peek into tor-async-utilsJim Newsome2024-08-291-2/+2
|
* extract tor_async_utils::oneshot into ::oneshot-fused-workaroundJim Newsome2024-08-281-1/+1
| | | | | | | | | | | | | | Having this in the `tor-async-utils` crate prevents us from doing both of the following without introducing a circular dependency: * using it in `tor-rtmock` (which we currently do, particularly in tests). * using `tor-rtmock` to test things in `tor-async-utils`. We don't do this yet, but it is generally sensible to do so. In particular we want to move the `stream_peak` module there, which is currently tested with `tor-rtmock`. Moving this into its own crate avoids this circular dependency.
* flow-control: document idea for making more robustJim Newsome2024-08-211-0/+6
| | | | | From <https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2340#note_3062531>
* Circuit reactor: improve code commentsJim Newsome2024-08-211-3/+11
| | | | | In particular, clarify that stream-flow-control msgs don't get blocked on circuit congestion control.
* StreamPollSet: disallow polling ready streamsJim Newsome2024-08-211-8/+18
|
* StreamMap: Use StreamUnobtrusivePeeker instead of PeekableJim Newsome2024-08-211-4/+5
|
* tor-proto: Use PeekableStream to get rid of redundant bufferingJim Newsome2024-08-212-55/+86
| | | | | | | | | | | | | | | | | | | | | | | | | * Update `StreamPollSet` to require that its streams implement `PeekableStream`, and to not do its own buffering of values read from the stream. This avoids an extra layer of buffering for streams that already buffer a value, and makes the interior state a little simpler and more robust. It does have a downside of making the API a little less convenient, since the caller must do its own `poll_peek` call if it wants a reference to the item. * Update `StreamMap` to implement `PeekableStream` for `OpenStreamEntStream`, as it must to satisfy the updated `StreamPollSet` API. We have to somewhat constrain the `poll_ready_streams_iter` API to no longer return both a reference to the stream and the message. I don't see a way to return both while satisfying the borrow checker. Luckily we don't really need both anymore. * Update the Circuit reactor to handle the updated `StreamMap::poll_ready_streams_iter` API.
* Circuit reactor: Update comments about outbound message handlingJim Newsome2024-08-151-3/+7
|
* Circuit reactor: remove `'hop_streams` loopJim Newsome2024-08-131-33/+24
| | | | | | | | | | As clippy points out otherwise, this no longer actually loops. Since the iterator already guarantees that the messages it produces are ready to send with respect to flow control, and we've already validated that we can send with respect to the circuit window, the loop, we can always handle the first item from the iterator. i.e. this changes a `while let` to an `if let`.
* Circuit reactor: remove `'outer` loopJim Newsome2024-08-131-55/+50
| | | | This is no longer needed. Removing it shouldn't change any behavior.
* Circuit reactor: don't process streams when we don't have circuit windowJim Newsome2024-08-131-18/+11
| | | | | | | When we've exhausted circuit-level SENDME window, iterating over streams is likely to be a waste of CPU. Theoretically we might be able to send some messages that don't count towards windows, but on balance it doesn't seem worth it.
* StreamMap: apply stream flow control before making messages availableJim Newsome2024-08-132-17/+83
| | | | | | This prevents us from having to iterate over streams blocked on flow control inside the circuit reactor, and potentially allows further simplification.
* tor-proto: Encapsulate flow-controlJim Newsome2024-08-133-59/+54
| | | | | | Encapsulate flow-control into a separate object that partially abstracts away the difference between window-based (legacy) flow control and xon-based (prop324) flow control.
* Circuit reactor: remove unnecessary circ window precheckJim Newsome2024-08-131-21/+0
| | | | | | | | | Since we no longer have an outbound queue for each hop, and instead return an error here if there is insufficient circuit window to send a message, there's no need to pre-check whether we have sufficient window. If there's insufficient circuit window, we'll still return an error slightly later, after failing to take from the circuit window.
* StreamMap: rm stray commentJim Newsome2024-08-131-3/+0
|
* Merge branch 'streampollset-no-v' into 'main'David Goulet2024-08-131-1/+1
|\ | | | | | | | | StreamPollSet: remove redundant type parameter V See merge request tpo/core/arti!2334
| * StreamPollSet: remove redundant type parameter VJim Newsome2024-08-121-1/+1
| | | | | | | | | | This was required to be the same type as `S::Item`. We can just use `S::Item` directly.
* | tor-proto: removed CountedHashMapJim Newsome2024-08-122-542/+0
|/ | | | | | | | | | | This was written for use in StreamMap, with an eye towards potentially reusing it elsewhere. We no longer use it in StreamMap, so it's currently unused. Probably best to go ahead and remove it now and resurrect it if we decide we want it later than to maintain dead code (or to make it more widely available without more concrete use-cases).
* StreamMap: Merge rxs into open_streamsJim Newsome2024-08-081-72/+63
| | | | | | This simplifies the bookkeeping a bit, and clears a path towards updating the Streams in our StreamPollSet to directly respect flow control.
* StreamMap: Put open streams in their own map instead of CountedHashMapJim Newsome2024-08-082-137/+124
| | | | | | This temporarily results in *more* bookkeeping, but is a step towards putting the mpsc receivers back into `OpenStreamEnt`, and putting the whole `OpenStreamEnt`s into the `StreamPollSet`.
* StreamMap: test n_open_streamsJim Newsome2024-08-081-1/+13
|
* StreamPollSet: allow access to inner streamsJim Newsome2024-08-081-9/+11
|
* tor-proto streammap: Drop receiver for outgoing messages after ENDJim Newsome2024-08-061-0/+4
| | | | Fixes #1513
* tor-proto: add Debug impls and improve panic messageJim Newsome2024-08-063-2/+8
| | | | For debugging #1513
* tor-proto: Remove circuit reactor's outbound bufferJim Newsome2024-08-011-71/+13
| | | | | | | We no longer need this. StreamMap now supports handling only one outgoing message at a time while ensuring no streams starve, so we no longer ever pull messages out of the map when we're not actually ready to send them.
* tor-proto::circuit::StreamMap: Use StreamPollSetJim Newsome2024-08-013-75/+128
| | | | | | | | | | | | | | | | | | | | * Refactors `StreamMap` to use `StreamPollSet` to manage its receivers for mpsc streams. * Extends `StreamMap` to support iterating only over streams that have a pending outgoing message, and in round-robin order. * Updates `circuit::reactor::Reactor` to use this functionality. It now iterates only over streams that have a ready outgoing message, and only actually "pops" a message that is ready to be sent. This mildly simplifies the circuit reactor, but more importantly clears the way to: * Remove the "outbound queue" of messages that were pulled from stream channels but that we couldn't send yet due to congestion control. * Support opportunistic packing when preparing to send a relay message. (proposal 340). * Refactor the circuit reactor's `run_once` into futures that we can `select!` over.
* circuit reactor: add comment pointing to tests in other moduleJim Newsome2024-07-291-1/+3
|
* Fix two TODO ticket numbersIan Jackson2024-06-251-1/+1
| | | | | I seem to have mistyped this ticket number. We meant #1397 aka "Circuit reactor isn't great", not some release ticket.
* Merge branch 'sometimes-unbounded' into 'main'Nick Mathewson2024-06-111-50/+13
|\ | | | | | | | | RFC: Provide and use SometimesUnboundedSender in circuit reactor See merge request tpo/core/arti!2172
| * Use SometimesUnboundedSink for the circuit reactor's bag-on-the-sideIan Jackson2024-05-291-50/+13
| |
* | Merge branch 'poll-ready-unpin-bool' into 'main'Nick Mathewson2024-05-291-3/+4
|\| | | | | | | | | Tidy up the ChannelSender::poll_ready inherent method See merge request tpo/core/arti!2171
| * ChannelSender::poll_ready_unpin_bool: move to utilIan Jackson2024-05-291-1/+1
| | | | | | | | This is where it belongs.
| * ChannelSender::poll_ready_unpin_bool: extension traitIan Jackson2024-05-291-0/+1
| | | | | | | | | | | | | | This makes this available for any Sink + Unpin. Which we want because we're about to wrap our ChannelSender in a Sink wrapper. It's in the wrong place now; we'll move it in a moment.
| * ChannelSender::poll_ready_unpin_bool: rename from poll_readyIan Jackson2024-05-291-3/+3
| | | | | | | | | | | | | | | | | | | | This would otherwise shadow the poll_ready method, which is confusing. Also this paves the way for making it available for any Sink + Unpin. Improve the docs somewhat to explain what this thing actually is.
* | proto: Make DataWriter::close actually do something.Nick Mathewson2024-05-291-2/+6
|/ | | | | | | | | | | | | | | | | | | Previously we had a bug where `<DataWriter as AsyncWrite>::close` (or `shutdown` in tokio-land) would not actually have any effect. It _would_ drop the `StreamTarget` held by the `DataWriter`, but since the `DataReader` also held a `StreamTarget`, the MPSC channel would not get closed, and the circuit reactor would not realize that the stream wanted to shut down. Now we use `mpsc::Sender::close_channel` to make our closes effectual. Closes #1368. Additionally, we fix a bug where `poll_close()` never actually did anything if the buffer had nothing in it when it was called. Previously, `poll_flush_impl()` would exit immediately if it had no data to flush. That isn't what we want when we are closing!
* proto: Make Channel explicitly Arc<.>Nick Mathewson2024-05-161-2/+2
| | | | | | | | | | | | | | | | Previously, Channel was a type that you could Clone that implicitly its state. Now, Channel always appears as an Arc<Channel>. This change has several benefits: * It makes the relationship between Channel struct and the underlying channel more clear. * It enables Channel to participate in the RPC system, where everything has to be an Arc<.> * It enables us to have a Weak<Channel>, if we ever want to. * It will let us move various members out of ChannelDetails. We did this change a while ago with ClientCirc.
* proto: Move Channel send functionality into a separate type.Nick Mathewson2024-05-161-9/+14
| | | | | | | | | | | | This serves three purposes: * It removes the 'send a cell' method from the channel's public API. Nothing outside of tor-proto should have to use this. * It paves the way for giving each circuit a separate handle onto the channel's send functionality. This will eventually let the channel multiplex among circuits more intelligently. * It prepares for the next commit, which will make Channel itself universally Arc<.>ed.
* proto: Explicitly enforce maxima on SENDME windows.Nick Mathewson2024-05-142-4/+15
| | | | | | | | | | | | | | No actual bug here, just technical debt: For `SendWindow`s, our tag system already ensured that we rejected any SENDME that didn't correspond to an appropriate drain. Still, it doesn't hurt to check. For `RecvWindow`s, it would have been a protocol violation if we ever did this, but it makes sense to make it an internal error if we try. Part of #1383.
* Circuit reactor: use refutable let to unnest some codeJim Newsome2024-05-061-34/+35
|
* Circuit reactor: rename 'hop to 'hop_outboundJim Newsome2024-05-061-3/+3
| | | | | It was a bit misleading since it doesn't cover all processing for the hop.
* Circuit reactor run_once: remove a level of nestingJim Newsome2024-05-061-27/+27
| | | | | | | Get rid of an `if` block by changing the guarded loop to check its conditions at the beginning of the loop instead of the end. This is a slight behavior change, since previously channel readiness wasn't checked before the first iteration of the loop.
* circuit reactor run_once: remove a level of nestingJim Newsome2024-05-061-90/+87
| | | | | | This should be a pure refactor. We remove a large if block and modify the first loop inside it to check whether the channel is ready before each attempt to send a message instead of after.
* Circuit reactor: document some requirements and assumptionsJim Newsome2024-04-251-10/+42
| | | | | | | | There are some tricky bits here that implicitly assume particular behavior in other bits for correctness. Document these requirements and assumptions. Fixes arti#1373
* Add temporary allows for some dead code warningsIan Jackson2024-04-251-0/+1
|
* counted_map: Use educe(Default).Nick Mathewson2024-04-021-12/+4
|
* counted_map: Use PhantomData<fn(P)->P>Nick Mathewson2024-04-021-4/+4
| | | | This is always Send+Sync, and invariant with P.
* counted_map: Add some notes about correctness; downgrade unsafesNick Mathewson2024-04-022-13/+21
| | | | | (We're letting the "unchecked" suffix of this function be enough to indicate that it's risky to use.)
* streammap: Use an internal counted_hashmap to simplify invariant checkingNick Mathewson2024-03-282-43/+566
| | | | | | | | | | Instead of making `streammap.rs` responsible for keeping track of a count field, this lowers that functionality into a lower-level CountedHashMap type. Said type has a little more functionality than we need, to sketch out how we'd want to develop it moving forward if we find that it's useful elsewhere. Closes #1344.
* Make filter conditional, to fix build with hs-service disabled.Nick Mathewson2024-03-261-2/+3
|