Kill haveged only if we are the last create_ap instance

This commit is contained in:
oblique 2015-05-02 01:01:33 +03:00
parent 661a8aa1b7
commit 8f112390b2

View File

@ -399,11 +399,7 @@ haveged_watchdog() {
elif ! pidof haveged > /dev/null 2>&1; then elif ! pidof haveged > /dev/null 2>&1; then
echo "Low entropy detected, starting haveged" echo "Low entropy detected, starting haveged"
# boost low-entropy # boost low-entropy
haveged -w 1024 -F > /dev/null 2>&1 & haveged -w 1024 -p $COMMON_CONFDIR/haveged.pid
local haveged_pid=$!
echo $haveged_pid > $CONFDIR/haveged.pid
mutex_unlock
wait $haveged_pid
fi fi
fi fi
mutex_unlock mutex_unlock
@ -601,32 +597,35 @@ HAVEGED_WATCHDOG_PID=
_cleanup() { _cleanup() {
local PID x local PID x
mutex_lock
trap "" SIGINT SIGUSR1 SIGUSR2 EXIT trap "" SIGINT SIGUSR1 SIGUSR2 EXIT
mutex_lock
disown -a
# kill haveged_watchdog # kill haveged_watchdog
[[ -n "$HAVEGED_WATCHDOG_PID" ]] && kill $HAVEGED_WATCHDOG_PID [[ -n "$HAVEGED_WATCHDOG_PID" ]] && kill $HAVEGED_WATCHDOG_PID
# exiting # kill processes
for x in $CONFDIR/*.pid; do for x in $CONFDIR/*.pid; do
# even if the $CONFDIR is empty, the for loop will assign # even if the $CONFDIR is empty, the for loop will assign
# a value in $x. so we need to check if the value is a file # a value in $x. so we need to check if the value is a file
if [[ -f $x ]]; then [[ -f $x ]] && kill -9 $(cat $x)
PID=$(cat $x)
disown $PID
kill -9 $PID
fi
done done
rm -rf $CONFDIR rm -rf $CONFDIR
# if we are the last create_ap instance then set back the common values # if we are the last create_ap instance then set back the common values
if ! has_running_instance; then if ! has_running_instance; then
# kill common processes
for x in $COMMON_CONFDIR/*.pid; do
[[ -f $x ]] && kill -9 $(cat $x)
done
# set old ip_forward # set old ip_forward
if [[ -f $COMMON_CONFDIR/ip_forward ]]; then if [[ -f $COMMON_CONFDIR/ip_forward ]]; then
cp $COMMON_CONFDIR/ip_forward /proc/sys/net/ipv4 cp $COMMON_CONFDIR/ip_forward /proc/sys/net/ipv4
rm -f $COMMON_CONFDIR/ip_forward rm -f $COMMON_CONFDIR/ip_forward
fi fi
# set old bridge-nf-call-iptables # set old bridge-nf-call-iptables
if [[ -f $COMMON_CONFDIR/bridge-nf-call-iptables ]]; then if [[ -f $COMMON_CONFDIR/bridge-nf-call-iptables ]]; then
if [[ -e /proc/sys/net/bridge/bridge-nf-call-iptables ]]; then if [[ -e /proc/sys/net/bridge/bridge-nf-call-iptables ]]; then
@ -634,6 +633,8 @@ _cleanup() {
fi fi
rm -f $COMMON_CONFDIR/bridge-nf-call-iptables rm -f $COMMON_CONFDIR/bridge-nf-call-iptables
fi fi
rm -rf $COMMON_CONFDIR
fi fi
if [[ "$SHARE_METHOD" != "none" ]]; then if [[ "$SHARE_METHOD" != "none" ]]; then