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.
This commit is contained in:
whitequark 2017-09-22 06:16:58 +00:00
parent f23bfe2014
commit d7da46fd3b
1 changed files with 1 additions and 2 deletions

View File

@ -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<u64>) {
self.timeout = duration;
self.remote_last_ts = None;
self.timeout = duration
}
/// Return the keep-alive interval.