diff --git a/src/device/socket/connectionmanager.rs b/src/device/socket/connectionmanager.rs index f873cdca..79a6da1e 100644 --- a/src/device/socket/connectionmanager.rs +++ b/src/device/socket/connectionmanager.rs @@ -226,10 +226,13 @@ impl VsockConnectionManager { 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 { 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.