add Connection::max_concurrent_recv_streams (#516)

This commit adds accessors to `client::Connection` and
`server::Connection` that return the current value of the
`SETTINGS_MAX_CONCURRENT_STREAMS` limit that has been sent by this peer
and acknowledged by the remote.

This is analogous to the `max_concurrent_send_streams` methods added in
PR #513. These accessors may be somewhat less useful than the ones for
the values negotiated by the remote, since users who care about this
limit are probably setting the builder parameter. However, it seems
worth having for completeness sake --- and it might be useful for
determining whether or not a configured concurrency limit has been acked
yet...

Part of #512
This commit is contained in:
Eliza Weisman
2021-02-25 08:58:19 -08:00
committed by GitHub
parent 89d91b0a4f
commit c1b411fc14
5 changed files with 53 additions and 7 deletions

View File

@@ -153,6 +153,12 @@ where
self.inner.streams.max_send_streams()
}
/// Returns the maximum number of concurrent streams that may be initiated
/// by the remote peer.
pub(crate) fn max_recv_streams(&self) -> usize {
self.inner.streams.max_recv_streams()
}
/// Returns `Ready` when the connection is ready to receive a frame.
///
/// Returns `RecvError` as this may raise errors that are caused by delayed

View File

@@ -173,6 +173,12 @@ impl Counts {
self.max_send_streams
}
/// Returns the maximum number of streams that can be initiated by the
/// remote peer.
pub(crate) fn max_recv_streams(&self) -> usize {
self.max_recv_streams
}
fn dec_num_streams(&mut self, stream: &mut store::Ptr) {
assert!(stream.is_counted);

View File

@@ -943,6 +943,10 @@ where
self.inner.lock().unwrap().counts.max_send_streams()
}
pub(crate) fn max_recv_streams(&self) -> usize {
self.inner.lock().unwrap().counts.max_recv_streams()
}
#[cfg(feature = "unstable")]
pub fn num_active_streams(&self) -> usize {
let me = self.inner.lock().unwrap();