Skip to content

Commit

Permalink
transport: Add Connection::stream_credit_avail_send()
Browse files Browse the repository at this point in the history
Gives a way for applications to know at least how much they can send
without hitting flow control. (They may still hit pacing and tx buffer
limits, of course.)

fixes mozilla#31
  • Loading branch information
Andy Grover committed May 29, 2019
1 parent 4d7faa0 commit ac7d97f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions neqo-transport/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,20 @@ impl Connection {
stream.send(data)
}

/// Bytes of available send stream credit, based upon current stream and
/// connection-level flow control values.
pub fn stream_credit_avail_send(&self, stream_id: u64) -> Res<u64> {
let stream = self
.send_streams
.get(&stream_id.into())
.ok_or_else(|| Error::InvalidStreamId)?;

Ok(min(
stream.credit_avail(),
self.flow_mgr.borrow().conn_credit_avail(),
))
}

/// Close the stream. Enqueued data will be sent.
pub fn stream_close_send(&mut self, stream_id: u64) -> Res<()> {
let stream = self
Expand Down

0 comments on commit ac7d97f

Please sign in to comment.