Преглед изворни кода

Change the function to retrieve used buffer instead of available buffer (#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 <aliceywang@google.com>
Co-authored-by: Andrew Walbran <qwandor@google.com>
Alice Wang пре 1 година
родитељ
комит
9a6947e40b
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      src/device/socket/connectionmanager.rs

+ 5 - 2
src/device/socket/connectionmanager.rs

@@ -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.