mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-10-09 03:42:20 +08:00
修复: 无限等待
Signed-off-by: shenmo <jifengshenmo@outlook.com>
This commit is contained in:
parent
4c59762086
commit
90ed903197
@ -231,17 +231,25 @@ _create_lock()
|
|||||||
{
|
{
|
||||||
eval "exec $LCK_FD>\"$LCK_FILE.lock\""
|
eval "exec $LCK_FD>\"$LCK_FILE.lock\""
|
||||||
|
|
||||||
# trap "cleanup_aptfast; exit_cleanup_state" EXIT
|
# 设置 trap 来清理资源
|
||||||
# This will hide the exit code
|
|
||||||
trap "cleanup_aptfast" EXIT
|
trap "cleanup_aptfast" EXIT
|
||||||
trap "cleanup_aptfast; exit 1" INT TERM
|
trap "cleanup_aptfast; exit 1" INT TERM
|
||||||
timer=0
|
|
||||||
until $(flock -xn $LCK_FD);do
|
timer=0
|
||||||
msg_already_running
|
max_wait=180 # 最大等待时间为180秒(3分钟)
|
||||||
sleep 1
|
|
||||||
let timer+=1
|
until $(flock -xn $LCK_FD); do
|
||||||
done
|
msg_already_running
|
||||||
unset timer
|
sleep 1
|
||||||
|
let timer+=1
|
||||||
|
|
||||||
|
if [ $timer -ge $max_wait ]; then
|
||||||
|
echo "timeout"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
unset timer
|
||||||
}
|
}
|
||||||
|
|
||||||
# unlock and remove the lock file
|
# unlock and remove the lock file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user