6in4: fix update timeout
The recent rework of the 6in4 endpoint update broke the retry mechanism. Rework the timeout handling and make the update status more verbose. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 44327
This commit is contained in:
parent
4b0fbf3072
commit
7be42a71e1
2 changed files with 28 additions and 8 deletions
|
@ -8,7 +8,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=6in4
|
PKG_NAME:=6in4
|
||||||
PKG_VERSION:=19
|
PKG_VERSION:=20
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=GPL-2.0
|
PKG_LICENSE:=GPL-2.0
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,19 @@
|
||||||
init_proto "$@"
|
init_proto "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proto_6in4_update() {
|
||||||
|
sh -c '
|
||||||
|
local timeout=5
|
||||||
|
|
||||||
|
(while [ $((timeout--)) -gt 0 ]; do
|
||||||
|
sleep 1
|
||||||
|
kill -0 $$ || exit 0
|
||||||
|
done; kill -9 $$) 2>/dev/null &
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
|
' "$1" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
proto_6in4_setup() {
|
proto_6in4_setup() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local iface="$2"
|
local iface="$2"
|
||||||
|
@ -97,13 +110,20 @@ proto_6in4_setup() {
|
||||||
local try=0
|
local try=0
|
||||||
local max=3
|
local max=3
|
||||||
|
|
||||||
while [ $((++try)) -le $max ]; do
|
(
|
||||||
( exec $urlget $urlget_opts "$url" | logger -t "$link" ) &
|
set -o pipefail
|
||||||
local pid=$!
|
while [ $((++try)) -le $max ]; do
|
||||||
( sleep 20; kill $pid 2>/dev/null ) &
|
if proto_6in4_update $urlget $urlget_opts "$url" 2>&1 | \
|
||||||
wait $pid && break
|
sed -e 's,^Killed$,timeout,' -e "s,^,update $try/$max: ," | \
|
||||||
sleep 20;
|
logger -t "$link";
|
||||||
done
|
then
|
||||||
|
logger -t "$link" "updated"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
logger -t "$link" "update failed"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue