From c00b3fe8cd4c84e7bb9c2b02ea9cdd30f81f8b39 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 24 Sep 2017 22:57:27 +0000 Subject: [PATCH] firmware: update smoltcp. --- artiq/firmware/Cargo.lock | 6 +++--- artiq/firmware/runtime/Cargo.toml | 2 +- artiq/firmware/runtime/sched.rs | 16 ++++++++++++++++ artiq/firmware/runtime/session.rs | 3 +++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/artiq/firmware/Cargo.lock b/artiq/firmware/Cargo.lock index 2ff4e8b6b..d4c926fef 100644 --- a/artiq/firmware/Cargo.lock +++ b/artiq/firmware/Cargo.lock @@ -157,7 +157,7 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "logger_artiq 0.0.0", "proto 0.0.0", - "smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=bf4ddef)", + "smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=6f5ae33)", "std_artiq 0.0.0", ] @@ -183,7 +183,7 @@ dependencies = [ [[package]] name = "smoltcp" version = "0.4.0" -source = "git+https://github.com/m-labs/smoltcp?rev=bf4ddef#bf4ddef87dae0e671dc8041b7fffd03376518e1e" +source = "git+https://github.com/m-labs/smoltcp?rev=6f5ae33#6f5ae33501827d57926469c6f1a860205a24f7ae" dependencies = [ "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -221,7 +221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec57723b84bbe7bdf76aa93169c9b59e67473317c6de3a83cb2a0f8ccb2aa493" "checksum managed 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d48e8c30a4363e2981fe4db20527f6ab0f32a243bbc75379dea5a64f60dae4" "checksum rustc-cfg 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56a596b5718bf5e059d59a30af12f7f462a152de147aa462b70892849ee18704" -"checksum smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=bf4ddef)" = "" +"checksum smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=6f5ae33)" = "" "checksum walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd7c16466ecc507c7cb5988db03e6eab4aaeab89a5c37a29251fcfd3ac9b7afe" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/artiq/firmware/runtime/Cargo.toml b/artiq/firmware/runtime/Cargo.toml index 8b654b373..5013d9878 100644 --- a/artiq/firmware/runtime/Cargo.toml +++ b/artiq/firmware/runtime/Cargo.toml @@ -37,6 +37,6 @@ features = ["alloc"] [dependencies.smoltcp] git = "https://github.com/m-labs/smoltcp" -rev = "bf4ddef" +rev = "6f5ae33" default-features = false features = ["alloc", "log"] diff --git a/artiq/firmware/runtime/sched.rs b/artiq/firmware/runtime/sched.rs index 11d5da676..b69f87da4 100644 --- a/artiq/firmware/runtime/sched.rs +++ b/artiq/firmware/runtime/sched.rs @@ -470,6 +470,22 @@ impl<'a> TcpStream<'a> { self.as_lower().remote_endpoint() } + pub fn timeout(&self) -> Option { + self.as_lower().timeout() + } + + pub fn set_timeout(&self, value: Option) { + self.as_lower().set_timeout(value) + } + + pub fn keep_alive(&self) -> Option { + self.as_lower().keep_alive() + } + + pub fn set_keep_alive(&self, value: Option) { + self.as_lower().set_keep_alive(value) + } + pub fn close(&self) -> Result<()> { self.as_lower().close(); until!(self, TcpSocketLower, |s| !s.is_open())?; diff --git a/artiq/firmware/runtime/session.rs b/artiq/firmware/runtime/session.rs index 9feb59d0b..fa698b198 100644 --- a/artiq/firmware/runtime/session.rs +++ b/artiq/firmware/runtime/session.rs @@ -634,6 +634,9 @@ pub fn thread(io: Io) { loop { if listener.can_accept() { let mut stream = listener.accept().expect("session: cannot accept"); + stream.set_timeout(Some(1000)); + stream.set_keep_alive(Some(500)); + match check_magic(&mut stream) { Ok(()) => (), Err(_) => {