Skip to content

add Connection::max_concurrent_recv_streams #516

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,14 +1242,29 @@ where
/// by this client.
///
/// This limit is configured by the server peer by sending the
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][settings] in a `SETTINGS`
/// frame. This method returns the currently acknowledged value recieved
/// from the remote.
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][1] in a `SETTINGS` frame.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this [1] change is half-way. The [settings]: .... below needs to be updated as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh whoops --- good catch!

/// This method returns the currently acknowledged value recieved from the
/// remote.
///
/// [settings]: https://tools.ietf.org/html/rfc7540#section-5.1.2
pub fn max_concurrent_send_streams(&self) -> usize {
self.inner.max_send_streams()
}

/// Returns the maximum number of concurrent streams that may be initiated
/// by the server on this connection.
///
/// This returns the value of the [`SETTINGS_MAX_CONCURRENT_STREAMS`
/// parameter][1] sent in a `SETTINGS` frame that has been
/// acknowledged by the remote peer. The value to be sent is configured by
/// the [`Builder::max_concurrent_streams`][2] method before handshaking
/// with the remote peer.
///
/// [1]: https://tools.ietf.org/html/rfc7540#section-5.1.2
/// [2]: ../struct.Builder.html#method.max_concurrent_streams
pub fn max_concurrent_recv_streams(&self) -> usize {
self.inner.max_recv_streams()
}
}

impl<T, B> Future for Connection<T, B>
Expand Down
6 changes: 6 additions & 0 deletions src/proto/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/proto/streams/counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions src/proto/streams/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
23 changes: 19 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,29 @@ where
/// by the server on this connection.
///
/// This limit is configured by the client peer by sending the
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][settings] in a `SETTINGS`
/// frame. This method returns the currently acknowledged value recieved
/// from the remote.
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][1] in a `SETTINGS` frame.
/// This method returns the currently acknowledged value recieved from the
/// remote.
///
/// [settings]: https://tools.ietf.org/html/rfc7540#section-5.1.2
/// [1]: https://tools.ietf.org/html/rfc7540#section-5.1.2
pub fn max_concurrent_send_streams(&self) -> usize {
self.connection.max_send_streams()
}

/// Returns the maximum number of concurrent streams that may be initiated
/// by the client on this connection.
///
/// This returns the value of the [`SETTINGS_MAX_CONCURRENT_STREAMS`
/// parameter][1] sent in a `SETTINGS` frame that has been
/// acknowledged by the remote peer. The value to be sent is configured by
/// the [`Builder::max_concurrent_streams`][2] method before handshaking
/// with the remote peer.
///
/// [1]: https://tools.ietf.org/html/rfc7540#section-5.1.2
/// [2]: ../struct.Builder.html#method.max_concurrent_streams
pub fn max_concurrent_recv_streams(&self) -> usize {
self.connection.max_recv_streams()
}
}

#[cfg(feature = "stream")]
Expand Down