mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-17 16:11:15 -03:00
Use explicit Timeout enum instead of magic constants
The FdReadableSet api was always intended to be converted to use Duration instead of usec/msec once the ffi was removed. This lets us be explicit about forever/infinite timeouts and removes the (small) chance of a collision between u64::MAX and INFINITE. I tried this out with `type Timeout = Option<Duration>` (only without the alias) but was unhappy with easy it is to accidentally use `None` when you meant a timeout of zero.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
str2wcstring, write_loop, WSL,
|
||||
};
|
||||
use crate::env::{EnvStack, Environment};
|
||||
use crate::fd_readable_set::FdReadableSet;
|
||||
use crate::fd_readable_set::{FdReadableSet, Timeout};
|
||||
use crate::flog::{FloggableDebug, FLOG};
|
||||
use crate::fork_exec::flog_safe::FLOG_SAFE;
|
||||
use crate::global_safety::RelaxedAtomicBool;
|
||||
@@ -334,9 +334,9 @@ fn readb(in_fd: RawFd, blocking: bool) -> ReadbResult {
|
||||
|
||||
// Here's where we call select().
|
||||
let select_res = fdset.check_readable(if blocking {
|
||||
FdReadableSet::kNoTimeout
|
||||
Timeout::Forever
|
||||
} else {
|
||||
0
|
||||
Timeout::ZERO
|
||||
});
|
||||
if select_res < 0 {
|
||||
let err = errno::errno().0;
|
||||
|
||||
Reference in New Issue
Block a user