Skip to content

Commit db22a82

Browse files
committed
select: allow infinite timeout
1 parent 7fa7206 commit db22a82

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/sys/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ pub fn select(nfds: c_int,
7171
readfds: Option<&mut FdSet>,
7272
writefds: Option<&mut FdSet>,
7373
errorfds: Option<&mut FdSet>,
74-
timeout: &mut TimeVal) -> Result<c_int> {
74+
timeout: Option<&mut TimeVal>) -> Result<c_int> {
7575
let readfds = readfds.map(|set| set as *mut FdSet).unwrap_or(null_mut());
7676
let writefds = writefds.map(|set| set as *mut FdSet).unwrap_or(null_mut());
7777
let errorfds = errorfds.map(|set| set as *mut FdSet).unwrap_or(null_mut());
78-
let timeout = timeout as *mut TimeVal;
78+
let timeout = timeout.map(|tv| tv as *mut TimeVal).unwrap_or(null_mut());
7979

8080
let res = unsafe {
8181
ffi::select(nfds, readfds, writefds, errorfds, timeout)

test/sys/test_select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_select() {
4646
Some(&mut fd_set),
4747
None,
4848
None,
49-
&mut timeout).unwrap());
49+
Some(&mut timeout)).unwrap());
5050
assert!(fd_set.contains(r1));
5151
assert!(!fd_set.contains(r2));
5252
}

0 commit comments

Comments
 (0)