Skip to content

Commit

Permalink
Change the function to retrieve used buffer instead of available buff…
Browse files Browse the repository at this point in the history
…er (#114)

* Change the function to retrieve used buffer instead of available buffer

The status of the used receive buffer is more helpful for users
when configuring credit updates.

* Use 'available' to mean bytes available to read.

---------

Co-authored-by: Alice Wang <[email protected]>
Co-authored-by: Andrew Walbran <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2023
1 parent 150740b commit 9a6947e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/device/socket/connectionmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ impl<H: Hal, T: Transport> VsockConnectionManager<H, T> {
Ok(bytes_read)
}

/// Returns the number of bytes currently available in the recv buffer.
/// Returns the number of bytes in the receive buffer available to be read by `recv`.
///
/// When the available bytes is 0, it indicates that the receive buffer is empty and does not
/// contain any data.
pub fn recv_buffer_available_bytes(&mut self, peer: VsockAddr, src_port: u32) -> Result<usize> {
let (_, connection) = get_connection(&mut self.connections, peer, src_port)?;
Ok(connection.buffer.available())
Ok(connection.buffer.used())
}

/// Sends a credit update to the given peer.
Expand Down

0 comments on commit 9a6947e

Please sign in to comment.