From 43401696839d7fa027228b2a6ab9f25924e5adb4 Mon Sep 17 00:00:00 2001 From: athena Date: Thu, 5 Dec 2024 00:09:17 +0530 Subject: [PATCH 1/3] Fixed stucking at infinte loop --- do.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/do.sh b/do.sh index 7789c47..c76aab3 100755 --- a/do.sh +++ b/do.sh @@ -584,18 +584,22 @@ gen_openconfig_models_sdk() { } wait_for_sock() { - start=$SECONDS TIMEOUT_SECONDS=30 if [ ! -z "${3}" ] then TIMEOUT_SECONDS=${3} fi + echo "Waiting for ${1}:${2} to be ready (timeout=${TIMEOUT_SECONDS}s)..." + start_time=$(date +%S) while true do nc -z -v ${1} ${2} && return 0 - elapsed=$(( SECONDS - start )) + current_time=$(date +%S) + elapsed=$(( current_time - start_time )) + # echo "elapsed time: $elapsed" + if [ $elapsed -gt ${TIMEOUT_SECONDS} ] then echo "${1}:${2} to be ready after ${TIMEOUT_SECONDS}s" From 844a667d48527763ee848b4457176dc2da6d6deb Mon Sep 17 00:00:00 2001 From: Biplab Mal Date: Thu, 5 Dec 2024 11:40:16 +0530 Subject: [PATCH 2/3] Update do.sh --- do.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/do.sh b/do.sh index c76aab3..3e9a37b 100755 --- a/do.sh +++ b/do.sh @@ -598,7 +598,7 @@ wait_for_sock() { current_time=$(date +%S) elapsed=$(( current_time - start_time )) - # echo "elapsed time: $elapsed" + echo "elapsed time: $elapsed" if [ $elapsed -gt ${TIMEOUT_SECONDS} ] then From 23876df6f8332cd77c18ff8be93ba97c7d9f275b Mon Sep 17 00:00:00 2001 From: athena Date: Thu, 5 Dec 2024 15:25:48 +0530 Subject: [PATCH 3/3] Fixed negative counting --- do.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/do.sh b/do.sh index 3e9a37b..b30dc25 100755 --- a/do.sh +++ b/do.sh @@ -589,20 +589,20 @@ wait_for_sock() { then TIMEOUT_SECONDS=${3} fi - echo "Waiting for ${1}:${2} to be ready (timeout=${TIMEOUT_SECONDS}s)..." - start_time=$(date +%S) + elapsed=0 + TIMEOUT_SECONDS=$(($TIMEOUT_SECONDS * 10)) while true do nc -z -v ${1} ${2} && return 0 - current_time=$(date +%S) - elapsed=$(( current_time - start_time )) - echo "elapsed time: $elapsed" + elapsed=$(($elapsed+1)) + # echo "Timeout: $TIMEOUT_SECONDS" + # echo "elapsed time: $elapsed" if [ $elapsed -gt ${TIMEOUT_SECONDS} ] then - echo "${1}:${2} to be ready after ${TIMEOUT_SECONDS}s" + echo "${1}:${2} to be ready after ${TIMEOUT_SECONDS}" exit 1 fi sleep 0.1