diff --git a/CHANGELOG.md b/CHANGELOG.md index b1bb2a61..1d5c2c45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.6.0 + +Upgrade step 2 of 4. This version sets the non-standard flag, version 0.5.0 +already recognises. + # 0.5.0 This version begins the upgrade process spawning multiple versions that diff --git a/Cargo.toml b/Cargo.toml index db2bb82a..d8855d02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yamux" -version = "0.5.0" +version = "0.6.0" authors = ["Parity Technologies "] license = "Apache-2.0 OR MIT" description = "Multiplexer over reliable, ordered connections" diff --git a/src/connection.rs b/src/connection.rs index 20b2a882..aae4f76a 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -463,23 +463,20 @@ impl Connection { } 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 @@ -489,7 +486,7 @@ impl Connection { 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); diff --git a/src/frame/header.rs b/src/frame/header.rs index a0538c25..2e4bb7aa 100644 --- a/src/frame/header.rs +++ b/src/frame/header.rs @@ -99,6 +99,11 @@ impl Header { 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 Header { diff --git a/src/lib.rs b/src/lib.rs index c6d7bd32..bbb162fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,15 +76,13 @@ pub enum WindowUpdateMode { /// - max. number of streams = 8192 /// - window update mode = on receive /// - read after close = true -/// - lazy open = false #[derive(Debug, Clone)] pub struct Config { receive_window: u32, max_buffer_size: usize, max_num_streams: usize, window_update_mode: WindowUpdateMode, - read_after_close: bool, - lazy_open: bool + read_after_close: bool } impl Default for Config { @@ -94,8 +92,7 @@ impl Default for Config { max_buffer_size: 1024 * 1024, max_num_streams: 8192, window_update_mode: WindowUpdateMode::OnReceive, - read_after_close: true, - lazy_open: false + read_after_close: true } } } @@ -149,8 +146,8 @@ impl Config { /// to the remote. This allows opening a stream with a custom receive /// window size (cf. [`Config::set_receive_window`]) which the remote /// can directly make use of. - pub fn set_lazy_open(&mut self, b: bool) -> &mut Self { - self.lazy_open = b; + #[deprecated(since = "0.6.0")] + pub fn set_lazy_open(&mut self, _: bool) -> &mut Self { self } } diff --git a/src/tests.rs b/src/tests.rs index 6a3a7998..fc661a68 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -221,7 +221,6 @@ impl Arbitrary for TestConfig { } else { WindowUpdateMode::OnReceive }); - c.set_lazy_open(g.gen()); c.set_read_after_close(g.gen()); c.set_receive_window(g.gen_range(256 * 1024, 1024 * 1024)); TestConfig(c)