Skip to content

Commit

Permalink
Timeouts: SendTimeout/write ReadTimeout/read
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
robem authored and jalil-salame committed Jul 24, 2023
1 parent 41d1faa commit 68dd544
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ impl VsockStream {
/// Set the timeout on read operations.
pub fn set_read_timeout(&self, dur: Option<Duration>) -> 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<Duration>) -> 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.
Expand Down

0 comments on commit 68dd544

Please sign in to comment.