fix(tcp/write_buf): incorrect return value

On success, the number of bytes written should be returned.

Previously `buf.len()` was always returned. The function `send_slice`
> ... returns the amount of octets actually enqueued, which is limited
> by the amount of free space in the transmit buffer; down to zero.

"down to zero" is okay as that is checked by `can_send`.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2026-06-25 23:55:00 +10:00
parent 7bfca6c5ab
commit cdea756569
+1 -2
View File
@@ -162,8 +162,7 @@ impl<'a> SchemeSocket for TcpSocket<'a> {
} else if !self.is_active() {
Err(SyscallError::new(syscall::ENOTCONN))
} else if self.can_send() {
self.send_slice(buf).expect("Can't send slice");
Ok(buf.len())
Ok(self.send_slice(buf).expect("Can't send slice"))
} else if file.flags & syscall::O_NONBLOCK == syscall::O_NONBLOCK {
Err(SyscallError::new(syscall::EAGAIN))
} else {