Skip to content

Commit

Permalink
Fix non_blocking_read signature (#81)
Browse files Browse the repository at this point in the history
should take mutable reference to buffer.
  • Loading branch information
NobodyXu committed Apr 12, 2024
1 parent e939b31 commit 36a5e2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Client {
{
let read = self.read().as_raw_fd();
loop {
match non_blocking_read(read, &buf) {
match non_blocking_read(read, &mut buf) {
Ok(1) => return Ok(Some(Acquired { byte: buf[0] })),
Ok(_) => {
return Err(io::Error::new(
Expand Down Expand Up @@ -587,7 +587,7 @@ fn cvt_ssize(t: libc::ssize_t) -> io::Result<libc::ssize_t> {
}

#[cfg(target_os = "linux")]
fn non_blocking_read(fd: c_int, buf: &[u8]) -> io::Result<usize> {
fn non_blocking_read(fd: c_int, buf: &mut [u8]) -> io::Result<usize> {
static IS_NONBLOCKING_READ_UNSUPPORTED: AtomicBool = AtomicBool::new(false);

if IS_NONBLOCKING_READ_UNSUPPORTED.load(Ordering::Relaxed) {
Expand Down

0 comments on commit 36a5e2e

Please sign in to comment.