From f748b5ba24bc94d1eb3a13747e4a5958ae4981de Mon Sep 17 00:00:00 2001 From: Xianhua Zhou Date: Fri, 21 Oct 2022 10:00:06 +0800 Subject: [PATCH] wait for connection on local address only --- files/glbd.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/files/glbd.sh b/files/glbd.sh index 5cec42f..a74992a 100755 --- a/files/glbd.sh +++ b/files/glbd.sh @@ -61,11 +61,15 @@ else fi wait_for_connections_to_drop() { - while (netstat -na | grep -m 1 ":$LISTEN_PORT " > /dev/null); do - echo "[`date`] $prog: waiting for lingering sockets to clear up..." - sleep 1s - done; - return 0 + _LISTEN_ADDR=$LISTEN_ADDR + if [ "$_LISTEN_ADDR" = "$LISTEN_PORT" ]; then + _LISTEN_ADDR=":"$LISTEN_PORT + fi + while (netstat -na | awk '{ print $4 }' | grep "$_LISTEN_ADDR" > /dev/null); do + echo "[`date`] $prog: waiting for lingering sockets to clear up..." + sleep 1s + done; + return 0 } stop() {