diff --git a/env_universal.cpp b/env_universal.cpp index 8d64923ee..69b1f5459 100644 --- a/env_universal.cpp +++ b/env_universal.cpp @@ -526,13 +526,3 @@ void env_universal_get_names(wcstring_list_t &lst, show_unexported); } - -bool synchronizes_via_fishd() -{ - if (program_name && ! wcscmp(program_name, L"fishd")) - { - /* fishd always wants to use fishd */ - return true; - } - return false; -} diff --git a/env_universal.h b/env_universal.h index dd4869112..a77efb1f5 100644 --- a/env_universal.h +++ b/env_universal.h @@ -70,7 +70,4 @@ void env_universal_get_names(wcstring_list_t &list, */ void env_universal_barrier(); -/* Temporary */ -bool synchronizes_via_fishd(); - #endif diff --git a/env_universal_common.cpp b/env_universal_common.cpp index cddb624c4..1a6a95d0d 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -1900,8 +1900,18 @@ class universal_notifier_named_pipe_t : public universal_notifier_t } }; +class universal_notifier_null_t : public universal_notifier_t +{ + /* Does nothing! */ +}; + static universal_notifier_t::notifier_strategy_t fetch_default_strategy_from_environment() { + if (! synchronizes_via_fishd()) + { + return universal_notifier_t::strategy_null; + } + universal_notifier_t::notifier_strategy_t result = universal_notifier_t::strategy_default; const struct @@ -1983,6 +1993,9 @@ universal_notifier_t *universal_notifier_t::new_notifier_for_strategy(universal_ case strategy_named_pipe: return new universal_notifier_named_pipe_t(test_path); + + case strategy_null: + return new universal_notifier_null_t(); default: fprintf(stderr, "Unsupported strategy %d\n", strat); @@ -2022,3 +2035,23 @@ bool universal_notifier_t::notification_fd_became_readable(int fd) { return false; } + +static bool initialize_synchronizes_via_fishd() +{ + const char *tmp = getenv("fish_use_fishd"); + return tmp != NULL && from_string(tmp); +} + +bool synchronizes_via_fishd() +{ + if (program_name && ! wcscmp(program_name, L"fishd")) + { + /* fishd always wants to use fishd */ + return true; + } + + /* Note that in general we can't change this once it's been set, so we only load it once */ + static bool result = initialize_synchronizes_via_fishd(); + return result; +} + diff --git a/env_universal_common.h b/env_universal_common.h index a3307e5c6..c4eda46bf 100644 --- a/env_universal_common.h +++ b/env_universal_common.h @@ -302,7 +302,10 @@ class universal_notifier_t strategy_inotify, // Strategy that uses notify(3). Simple and efficient, but OS X only. - strategy_notifyd + strategy_notifyd, + + // Null notifier, does nothing + strategy_null }; protected: @@ -343,6 +346,9 @@ class universal_notifier_t std::string get_machine_identifier(); bool get_hostname_identifier(std::string *result); +/* Temporary */ +bool synchronizes_via_fishd(); + /* Environment variable for requesting a particular universal notifier. See fetch_default_strategy_from_environment for names. */ #define UNIVERSAL_NOTIFIER_ENV_NAME "fish_universal_notifier" diff --git a/input_common.cpp b/input_common.cpp index 719659406..1252dc0d4 100644 --- a/input_common.cpp +++ b/input_common.cpp @@ -124,7 +124,7 @@ static wint_t readb() fd_max = maxi(fd_max, notifier_fd); } - /* Get the suggested delay (possibly none) */ + /* Get its suggested delay (possibly none) */ struct timeval tv = {}; const unsigned long usecs_delay = notifier.usec_delay_between_polls(); if (usecs_delay > 0)