Skip to content

Commit 5440a1f

Browse files
authored
Auto merge of #36322 - uweigand:nonblocking, r=alexcrichton
Fix argument to FIONBIO ioctl The FIONBIO ioctl takes as argument a pointer to an integer, which should be either 0 or 1 to indicate whether nonblocking mode is to be switched off or on. The type of the pointed-to variable is "int". However, the set_nonblocking routine in libstd/sys/unix/net.rs passes a pointer to a libc::c_ulong variable. This doesn't matter on all 32-bit platforms and on all litte-endian platforms, but it will break on big-endian 64-bit platforms. Found while porting Rust to s390x (a big-endian 64-bit platform). Signed-off-by: Ulrich Weigand <[email protected]>
2 parents 1df6445 + 3f0462a commit 5440a1f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/sys/unix/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl Socket {
213213
}
214214

215215
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
216-
let mut nonblocking = nonblocking as libc::c_ulong;
216+
let mut nonblocking = nonblocking as libc::c_int;
217217
cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(|_| ())
218218
}
219219

0 commit comments

Comments
 (0)