Merge branch 'half_stream_connected_ok' into 'main'
tor-proto: set HalfStream::connected_ok right. See merge request tpo/core/arti!203
This commit is contained in:
commit
53d084fdb6
|
@ -1186,6 +1186,7 @@ impl Reactor {
|
||||||
sink,
|
sink,
|
||||||
send_window,
|
send_window,
|
||||||
dropped,
|
dropped,
|
||||||
|
ref mut received_connected,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
// The stream for this message exists, and is open.
|
// The stream for this message exists, and is open.
|
||||||
|
@ -1198,6 +1199,13 @@ impl Reactor {
|
||||||
return Ok(CellStatus::Continue);
|
return Ok(CellStatus::Continue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches!(msg, RelayMsg::Connected(_)) {
|
||||||
|
// Remember that we've received a Connected cell, and can't get another,
|
||||||
|
// even if we become a HalfStream. (This rule is enforced separately at
|
||||||
|
// DataStreamReader.)
|
||||||
|
*received_connected = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Remember whether this was an end cell: if so we should
|
// Remember whether this was an end cell: if so we should
|
||||||
// close the stream.
|
// close the stream.
|
||||||
let is_end_cell = matches!(msg, RelayMsg::End(_));
|
let is_end_cell = matches!(msg, RelayMsg::End(_));
|
||||||
|
|
|
@ -31,6 +31,9 @@ pub(super) enum StreamEnt {
|
||||||
/// Number of cells dropped due to the stream disappearing before we can
|
/// Number of cells dropped due to the stream disappearing before we can
|
||||||
/// transform this into an `EndSent`.
|
/// transform this into an `EndSent`.
|
||||||
dropped: u16,
|
dropped: u16,
|
||||||
|
/// True iff we've received a CONNECTED cell on this stream.
|
||||||
|
/// (This is redundant with `DataStreamReader::connected`.)
|
||||||
|
received_connected: bool,
|
||||||
},
|
},
|
||||||
/// A stream for which we have received an END cell, but not yet
|
/// A stream for which we have received an END cell, but not yet
|
||||||
/// had the stream object get dropped.
|
/// had the stream object get dropped.
|
||||||
|
@ -110,6 +113,7 @@ impl StreamMap {
|
||||||
rx,
|
rx,
|
||||||
send_window,
|
send_window,
|
||||||
dropped: 0,
|
dropped: 0,
|
||||||
|
received_connected: false,
|
||||||
};
|
};
|
||||||
// This "65536" seems too aggressive, but it's what tor does.
|
// This "65536" seems too aggressive, but it's what tor does.
|
||||||
//
|
//
|
||||||
|
@ -182,6 +186,7 @@ impl StreamMap {
|
||||||
StreamEnt::Open {
|
StreamEnt::Open {
|
||||||
send_window,
|
send_window,
|
||||||
dropped,
|
dropped,
|
||||||
|
received_connected,
|
||||||
// notably absent: the channels for sink and stream, which will get dropped and
|
// notably absent: the channels for sink and stream, which will get dropped and
|
||||||
// closed (meaning reads/writes from/to this stream will now fail)
|
// closed (meaning reads/writes from/to this stream will now fail)
|
||||||
..
|
..
|
||||||
|
@ -192,8 +197,8 @@ impl StreamMap {
|
||||||
let mut recv_window = StreamRecvWindow::new(RECV_WINDOW_INIT);
|
let mut recv_window = StreamRecvWindow::new(RECV_WINDOW_INIT);
|
||||||
recv_window.decrement_n(dropped)?;
|
recv_window.decrement_n(dropped)?;
|
||||||
// TODO: would be nice to avoid new_ref.
|
// TODO: would be nice to avoid new_ref.
|
||||||
// XXXX: We should set connected_ok properly.
|
// If we haven't gotten a CONNECTED already, we accept one on the half-stream.
|
||||||
let connected_ok = true;
|
let connected_ok = !received_connected;
|
||||||
let halfstream = HalfStream::new(send_window, recv_window, connected_ok);
|
let halfstream = HalfStream::new(send_window, recv_window, connected_ok);
|
||||||
self.m.insert(id, StreamEnt::EndSent(halfstream));
|
self.m.insert(id, StreamEnt::EndSent(halfstream));
|
||||||
Ok(ShouldSendEnd::Send)
|
Ok(ShouldSendEnd::Send)
|
||||||
|
|
Loading…
Reference in New Issue