Reduce named pipe uvar notifier poll time from 100 msec to 10 msec

To broadcast a uvar change on Linux, we write to a named pipe, wait a bit,
and then read it back. While the pipe is readable, fish will enter a "polling
mode" where it will check for uvar changes every N msec, until the pipe is no
longer readable. If the pipe stays readable for too long (5 seconds), fish
will try to drain it; this may happen if broadcasting instance of fish is
killed before it can read back its data.

In #8209 we have a case where fish is launched in the background to set a
uvar, and then immediately exits, leaving data on the pipe. This means that
we are perpetually in a polling mode until we hit that timeout. Reduce the
timeout to 1 second and the polling interval to 10 msec.

This improves #8209; it doesn't fix it fully but I think it's the best we can
do absent some other IPC mechanism.
This commit is contained in:
ridiculousfish 2021-09-16 15:25:22 -07:00
parent 7f71df0905
commit d6075885ef

View file

@ -1303,10 +1303,10 @@ class universal_notifier_named_pipe_t final : public universal_notifier_t {
size_t drain_amount{0};
// We "flash" the pipe to make it briefly readable, for this many usec.
static constexpr long long k_flash_duration_usec = 1e5;
static constexpr long long k_flash_duration_usec = 1e4;
// If the pipe remains readable for this many usec, we drain it.
static constexpr long long k_readable_too_long_duration_usec = 5e6;
static constexpr long long k_readable_too_long_duration_usec = 1e6;
/// \return the name of a state.
static const char *state_name(state_t s) {