From bb633bde22cfe3d206c2a34c82a2d87aee8482e6 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Mon, 10 Oct 2022 17:54:49 +0200 Subject: daemon.sh: fixed race condition Signed-off-by: Toni Uhlig --- scripts/daemon.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'scripts') diff --git a/scripts/daemon.sh b/scripts/daemon.sh index 35dd08e83..a906253cd 100755 --- a/scripts/daemon.sh +++ b/scripts/daemon.sh @@ -44,6 +44,21 @@ else set -x ${2} -p "${NROOT}/nDPIsrvd-${NSUFFIX}.pid" -c "${NROOT}/nDPIsrvd-${NSUFFIX}-collector.sock" -s "${NROOT}/nDPIsrvd-${NSUFFIX}-distributor.sock" -d -L "${NROOT}/nDPIsrvd.log" test $? -eq 0 || RETVAL=1 + + MAX_TRIES=10 + while [ ! -S "${NROOT}/nDPIsrvd-${NSUFFIX}-collector.sock" -a ${MAX_TRIES} -gt 0 ]; do + sleep 0.5 + MAX_TRIES=$((MAX_TRIES - 1)) + done + test ${MAX_TRIES} -eq 0 && RETVAL=1 + + MAX_TRIES=10 + while [ ! -S "${NROOT}/nDPIsrvd-${NSUFFIX}-distributor.sock" -a ${MAX_TRIES} -gt 0 ]; do + sleep 0.5 + MAX_TRIES=$((MAX_TRIES - 1)) + done + test ${MAX_TRIES} -eq 0 && RETVAL=1 + sudo chgrp "$(id -n -g "${NUSER}")" "${NROOT}/nDPIsrvd-${NSUFFIX}-collector.sock" test $? -eq 0 || RETVAL=1 sudo chmod g+w "${NROOT}/nDPIsrvd-${NSUFFIX}-collector.sock" -- cgit v1.2.3