mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-07-01 08:11:14 -03:00
Allow using poll() to check for readability
Cygwin tests are failing because cygwin has a low limit of only 64 fds in select(). Extend select_wrapper_t to also support using poll(), according to a FISH_USE_POLL new define. All systems now use poll() except for Mac. Rename select_wrapper_t to fd_readable_set_t since now it may not wrap select(). This allows the deep-cmdsub.fish test to pass on Cygwin.
This commit is contained in:
@@ -60,7 +60,7 @@ using readb_result_t = int;
|
||||
static readb_result_t readb(int in_fd) {
|
||||
assert(in_fd >= 0 && "Invalid in fd");
|
||||
universal_notifier_t& notifier = universal_notifier_t::default_notifier();
|
||||
select_wrapper_t fdset;
|
||||
fd_readable_set_t fdset;
|
||||
for (;;) {
|
||||
fdset.clear();
|
||||
fdset.add(in_fd);
|
||||
@@ -75,13 +75,13 @@ static readb_result_t readb(int in_fd) {
|
||||
|
||||
// Get its suggested delay (possibly none).
|
||||
// Note a 0 here means do not poll.
|
||||
uint64_t timeout = select_wrapper_t::kNoTimeout;
|
||||
uint64_t timeout = fd_readable_set_t::kNoTimeout;
|
||||
if (uint64_t usecs_delay = notifier.usec_delay_between_polls()) {
|
||||
timeout = usecs_delay;
|
||||
}
|
||||
|
||||
// Here's where we call select().
|
||||
int select_res = fdset.select(timeout);
|
||||
int select_res = fdset.check_readable(timeout);
|
||||
if (select_res < 0) {
|
||||
if (errno == EINTR || errno == EAGAIN) {
|
||||
// A signal.
|
||||
@@ -225,7 +225,7 @@ maybe_t<char_event_t> input_event_queue_t::readch_timed() {
|
||||
}
|
||||
const uint64_t usec_per_msec = 1000;
|
||||
uint64_t timeout_usec = static_cast<uint64_t>(wait_on_escape_ms) * usec_per_msec;
|
||||
if (select_wrapper_t::is_fd_readable(in_, timeout_usec)) {
|
||||
if (fd_readable_set_t::is_fd_readable(in_, timeout_usec)) {
|
||||
return readch();
|
||||
}
|
||||
return none();
|
||||
|
||||
Reference in New Issue
Block a user