Skip to content

Commit

Permalink
Set additive flag in initial window update.
Browse files Browse the repository at this point in the history
  • Loading branch information
twittner committed Sep 2, 2020
1 parent 2380b43 commit 76278e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,23 +463,20 @@ impl<T: AsyncRead + AsyncWrite + Unpin> Connection<T> {
}
log::trace!("{}: creating new outbound stream", self.id);
let id = self.next_stream_id()?;
if !self.config.lazy_open {
let mut frame = Frame::window_update(id, self.config.receive_window);
let extra_credit = self.config.receive_window - DEFAULT_CREDIT;
if extra_credit > 0 {
let mut frame = Frame::window_update(id, extra_credit);
frame.header_mut().syn();
frame.header_mut().additive();
log::trace!("{}: sending initial {}", self.id, frame.header());
self.socket.get_mut().send(&frame).await.or(Err(ConnectionError::Closed))?
}
let stream = {
let config = self.config.clone();
let sender = self.stream_sender.clone();
let window =
if self.config.lazy_open {
DEFAULT_CREDIT
} else {
self.config.receive_window
};
let window = self.config.receive_window;
let mut stream = Stream::new(id, self.id, config, window, DEFAULT_CREDIT, sender);
if self.config.lazy_open {
if extra_credit == 0 {
stream.set_flag(stream::Flag::Syn)
}
stream
Expand All @@ -489,7 +486,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin> Connection<T> {
self.streams.insert(id, stream);
} else {
log::debug!("{}: open stream {} has been cancelled", self.id, id);
if !self.config.lazy_open {
if extra_credit > 0 {
let mut header = Header::data(id, 0);
header.rst();
let frame = Frame::new(header);
Expand Down
5 changes: 5 additions & 0 deletions src/frame/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ impl<T: HasSyn> Header<T> {
pub fn syn(&mut self) {
self.flags.0 |= SYN.0
}

/// Set the [`ADD`] flag.
pub fn additive(&mut self) {
self.flags.0 |= ADD.0
}
}

impl<T: HasAck> Header<T> {
Expand Down

0 comments on commit 76278e6

Please sign in to comment.