Skip to content

Commit 610f167

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 30ca832 commit 610f167

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
@@ -1242,14 +1242,29 @@ where
12421242
/// by this client.
12431243
///
12441244
/// This limit is configured by the server peer by sending the
1245-
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][settings] in a `SETTINGS`
1246-
/// frame. This method returns the currently acknowledged value recieved
1247-
/// from the remote.
1245+
/// [`SETTINGS_MAX_CONCURRENT_STREAMS` parameter][1] in a `SETTINGS` frame.
1246+
/// This method returns the currently acknowledged value recieved from the
1247+
/// remote.
12481248
///
12491249
/// [settings]: https://tools.ietf.org/html/rfc7540#section-5.1.2
12501250
pub fn max_concurrent_send_streams(&self) -> usize {
12511251
self.inner.max_send_streams()
12521252
}
1253+
1254+
/// Returns the maximum number of concurrent streams that may be initiated
1255+
/// by the server on this connection.
1256+
///
1257+
/// This returns the value of the [`SETTINGS_MAX_CONCURRENT_STREAMS`
1258+
/// parameter][1] sent in a `SETTINGS` frame that has been
1259+
/// acknowledged by the remote peer. The value to be sent is configured by
1260+
/// the [`Builder::max_concurrent_streams`][2] method before handshaking
1261+
/// with the remote peer.
1262+
///
1263+
/// [1]: https://tools.ietf.org/html/rfc7540#section-5.1.2
1264+
/// [2]: ../struct.Builder.html#method.max_concurrent_streams
1265+
pub fn max_concurrent_recv_streams(&self) -> usize {
1266+
self.inner.max_recv_streams()
1267+
}
12531268
}
12541269

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

src/proto/connection.rs

+6
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ where
153153
self.inner.streams.max_send_streams()
154154
}
155155

156+
/// Returns the maximum number of concurrent streams that may be initiated
157+
/// by the remote peer.
158+
pub(crate) fn max_recv_streams(&self) -> usize {
159+
self.streams.max_recv_streams()
160+
}
161+
156162
/// Returns `Ready` when the connection is ready to receive a frame.
157163
///
158164
/// 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
@@ -943,6 +943,10 @@ where
943943
self.inner.lock().unwrap().counts.max_send_streams()
944944
}
945945

946+
pub(crate) fn max_recv_streams(&self) -> usize {
947+
self.inner.lock().unwrap().counts.max_recv_streams()
948+
}
949+
946950
#[cfg(feature = "unstable")]
947951
pub fn num_active_streams(&self) -> usize {
948952
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)