diff --git a/vm-virtio/src/vsock/csm/txbuf.rs b/vm-virtio/src/vsock/csm/txbuf.rs index 1601b85ec..8e450b112 100644 --- a/vm-virtio/src/vsock/csm/txbuf.rs +++ b/vm-virtio/src/vsock/csm/txbuf.rs @@ -138,7 +138,11 @@ impl TxBuf { // Attempt our second write. This will return immediately if a second write isn't // needed, since checking for an empty buffer is the first thing we do in this // function. - Ok(written + self.flush_to(sink)?) + // + // Interesting corner case: if we've already written some data in the first pass, + // and then the second write fails, we will consider the flush action a success + // and return the number of bytes written in the first pass. + Ok(written + self.flush_to(sink).unwrap_or(0)) } /// Check if the buffer holds any data that hasn't yet been flushed out.