Pull request: all: fix race, imp scripts

Merge in DNS/adguard-home from fix-race to master

Squashed commit of the following:

commit dff47c707554f689cf131e0ab3fe05df4e4b6a51
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri May 21 19:12:06 2021 +0300

    all: fix race, imp scripts
This commit is contained in:
Ainar Garipov 2021-05-21 19:20:42 +03:00
parent 6847f7c8bb
commit 52e6a63d8c
4 changed files with 7 additions and 6 deletions

View File

@ -121,7 +121,9 @@ func (ehc *EtcHostsContainer) Close() {
if ehc.watcher != nil { if ehc.watcher != nil {
_ = ehc.watcher.Close() _ = ehc.watcher.Close()
} }
close(ehc.onlyWritesChan)
// Don't close onlyWritesChan here and let onlyWrites close it after
// watcher.Events is closed to prevent close races.
} }
// Process returns the list of IP addresses for the hostname or nil if nothing // Process returns the list of IP addresses for the hostname or nil if nothing
@ -298,6 +300,8 @@ func (ehc *EtcHostsContainer) onlyWrites() {
ehc.onlyWritesChan <- event ehc.onlyWritesChan <- event
} }
} }
close(ehc.onlyWritesChan)
} }
// Receive notifications from fsnotify package // Receive notifications from fsnotify package

View File

@ -27,8 +27,6 @@ else
fi fi
readonly version readonly version
echo $version
# Allow users to use sudo. # Allow users to use sudo.
sudo_cmd="${SUDO:-}" sudo_cmd="${SUDO:-}"
readonly sudo_cmd readonly sudo_cmd

View File

@ -11,9 +11,8 @@ fi
set -e -f -u set -e -f -u
dist_dir="$DIST_DIR" dist_dir="$DIST_DIR"
go="${GO:-go}"
sudo_cmd="${SUDO:-}" sudo_cmd="${SUDO:-}"
readonly dist_dir go sudo_cmd readonly dist_dir sudo_cmd
$sudo_cmd rm -f\ $sudo_cmd rm -f\
./AdGuardHome\ ./AdGuardHome\

View File

@ -136,7 +136,7 @@ exit_on_output() (
then then
if [ "$*" != '' ] if [ "$*" != '' ]
then then
echo "combined output of '$cmd $@':" echo "combined output of '$cmd $*':"
else else
echo "combined output of '$cmd':" echo "combined output of '$cmd':"
fi fi