From d7da46fd3b434dd7cd6e2ab1a1610d9fc2078e14 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 22 Sep 2017 06:16:58 +0000 Subject: [PATCH] Do not clear remote_last_ts in TcpSocket::set_timeout(). After this change, if an 1s timeout is set on a socket that received no packet for 2s, it will be instantly aborted, which seems more reasonable. Also, this makes the `self.remote_last_ts.is_none()` branch in TcpSocket::dispatch() actually behave as described. --- src/socket/tcp.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/socket/tcp.rs b/src/socket/tcp.rs index df46969..a3c5784 100644 --- a/src/socket/tcp.rs +++ b/src/socket/tcp.rs @@ -280,8 +280,7 @@ impl<'a> TcpSocket<'a> { /// * After enabling [keep-alive](#method.set_keep_alive), the remote endpoint exceeds /// the specified duration between any two packets it sends. pub fn set_timeout(&mut self, duration: Option) { - self.timeout = duration; - self.remote_last_ts = None; + self.timeout = duration } /// Return the keep-alive interval.