From 68dd5440778c9954d63b674c8cbf6096a867f76e Mon Sep 17 00:00:00 2001 From: robem Date: Fri, 21 Jul 2023 20:02:23 -0400 Subject: [PATCH] Timeouts: SendTimeout/write ReadTimeout/read This change fixes the implementation of `set_read_timeout` and `set_write_timeout` API. In the previous version, `set_read_timeout` would set the write timeout and vice versa. Signed-off-by: robem --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e482e9f..3dcc264 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -238,13 +238,13 @@ impl VsockStream { /// Set the timeout on read operations. pub fn set_read_timeout(&self, dur: Option) -> Result<()> { let timeout = Self::timeval_from_duration(dur)?.into(); - Ok(SendTimeout.set(self.socket, &timeout)?) + Ok(ReceiveTimeout.set(self.socket, &timeout)?) } /// Set the timeout on write operations. pub fn set_write_timeout(&self, dur: Option) -> Result<()> { let timeout = Self::timeval_from_duration(dur)?.into(); - Ok(ReceiveTimeout.set(self.socket, &timeout)?) + Ok(SendTimeout.set(self.socket, &timeout)?) } /// Retrieve the latest error associated with the underlying socket.