Skip to content

Commit eb34f08

Browse files
committed
add Connection::max_concurrent_recv_streams
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
1 parent 978c712 commit eb34f08

File tree

5 files changed

+53
-7
lines changed

5 files changed

+53
-7
lines changed

src/client.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -1233,14 +1233,29 @@ where
12331233
/// by this client.
12341234
///
12351235
/// This limit is configured by the server peer by sending the
1236-
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][settings] in a `SETTINGS`
1237-
/// frame. This method returns the currently acknowledged value recieved
1238-
/// from the remote.
1236+
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][1] in a `SETTINGS` frame.
1237+
/// This method returns the currently acknowledged value recieved from the
1238+
/// remote.
12391239
///
12401240
/// [settings]: https://tools.ietf.org/html/rfc7540#section-5.1.2
12411241
pub fn max_concurrent_send_streams(&self) -> usize {
12421242
self.inner.max_send_streams()
12431243
}
1244+
1245+
/// Returns the maximum number of concurrent streams that may be initiated
1246+
/// by the server on this connection.
1247+
///
1248+
/// This returns the value of the [`SETTINGS_MAX_CONCURRENT_STREAMS`
1249+
/// parameter][1] sent in a `SETTINGS` frame that has been
1250+
/// acknowledged by the remote peer. The value to be sent is configured by
1251+
/// the [`Builder::max_concurrent_streams`][2] method before handshaking
1252+
/// with the remote peer.
1253+
///
1254+
/// [1]: https://tools.ietf.org/html/rfc7540#section-5.1.2
1255+
/// [2]: ../struct.Builder.html#method.max_concurrent_streams
1256+
pub fn max_concurrent_recv_streams(&self) -> usize {
1257+
self.inner.max_recv_streams()
1258+
}
12441259
}
12451260

12461261
impl<T, B> Future for Connection<T, B>

src/proto/connection.rs

+6
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ where
126126
self.streams.max_send_streams()
127127
}
128128

129+
/// Returns the maximum number of concurrent streams that may be initiated
130+
/// by the remote peer.
131+
pub(crate) fn max_recv_streams(&self) -> usize {
132+
self.streams.max_recv_streams()
133+
}
134+
129135
/// Returns `Ready` when the connection is ready to receive a frame.
130136
///
131137
/// Returns `RecvError` as this may raise errors that are caused by delayed

src/proto/streams/counts.rs

+6
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ impl Counts {
173173
self.max_send_streams
174174
}
175175

176+
/// Returns the maximum number of streams that can be initiated by the
177+
/// remote peer.
178+
pub(crate) fn max_recv_streams(&self) -> usize {
179+
self.max_recv_streams
180+
}
181+
176182
fn dec_num_streams(&mut self, stream: &mut store::Ptr) {
177183
assert!(stream.is_counted);
178184

src/proto/streams/streams.rs

+4
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,10 @@ where
840840
self.inner.lock().unwrap().counts.max_send_streams()
841841
}
842842

843+
pub(crate) fn max_recv_streams(&self) -> usize {
844+
self.inner.lock().unwrap().counts.max_recv_streams()
845+
}
846+
843847
#[cfg(feature = "unstable")]
844848
pub fn num_active_streams(&self) -> usize {
845849
let me = self.inner.lock().unwrap();

src/server.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,29 @@ where
534534
/// by the server on this connection.
535535
///
536536
/// This limit is configured by the client peer by sending the
537-
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][settings] in a `SETTINGS`
538-
/// frame. This method returns the currently acknowledged value recieved
539-
/// from the remote.
537+
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][1] in a `SETTINGS` frame.
538+
/// This method returns the currently acknowledged value recieved from the
539+
/// remote.
540540
///
541-
/// [settings]: https://tools.ietf.org/html/rfc7540#section-5.1.2
541+
/// [1]: https://tools.ietf.org/html/rfc7540#section-5.1.2
542542
pub fn max_concurrent_send_streams(&self) -> usize {
543543
self.connection.max_send_streams()
544544
}
545+
546+
/// Returns the maximum number of concurrent streams that may be initiated
547+
/// by the client on this connection.
548+
///
549+
/// This returns the value of the [`SETTINGS_MAX_CONCURRENT_STREAMS`
550+
/// parameter][1] sent in a `SETTINGS` frame that has been
551+
/// acknowledged by the remote peer. The value to be sent is configured by
552+
/// the [`Builder::max_concurrent_streams`][2] method before handshaking
553+
/// with the remote peer.
554+
///
555+
/// [1]: https://tools.ietf.org/html/rfc7540#section-5.1.2
556+
/// [2]: ../struct.Builder.html#method.max_concurrent_streams
557+
pub fn max_concurrent_recv_streams(&self) -> usize {
558+
self.connection.max_recv_streams()
559+
}
545560
}
546561

547562
#[cfg(feature = "stream")]

0 commit comments

Comments
 (0)