mirror of
https://github.com/openwrt/packages.git
synced 2025-12-21 21:24:31 +04:00
Unbound: fix file lock race in odhcpd.sh
Signed-off-by: Ted Hess <thess@kitschensync.net>
This commit is contained in:
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=unbound
|
PKG_NAME:=unbound
|
||||||
PKG_VERSION:=1.21.0
|
PKG_VERSION:=1.21.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=https://nlnetlabs.nl/downloads/unbound
|
PKG_SOURCE_URL:=https://nlnetlabs.nl/downloads/unbound
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ odhcpd_zonedata() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
case $longconf in
|
case $longconf in
|
||||||
freshstart)
|
freshstart)
|
||||||
awk -v conffile=$UB_DHCP_CONF -v pipefile=$dns_ls_new \
|
awk -v conffile=$UB_DHCP_CONF -v pipefile=$dns_ls_new \
|
||||||
@@ -129,22 +128,11 @@ odhcpd_zonedata() {
|
|||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
UB_ODHPCD_LOCK=/tmp/unbound_odhcpd.lock
|
UB_ODHCPD_LOCK=/var/lock/unbound_odhcpd.lock
|
||||||
|
|
||||||
if [ ! -f $UB_ODHPCD_LOCK ] ; then
|
exec 1000>$UB_ODHCPD_LOCK
|
||||||
# imperfect but it should avoid collisions
|
if flock -x -n 1000 ; then
|
||||||
touch $UB_ODHPCD_LOCK
|
|
||||||
odhcpd_zonedata
|
odhcpd_zonedata
|
||||||
rm -f $UB_ODHPCD_LOCK
|
|
||||||
|
|
||||||
else
|
|
||||||
UB_ODHCPD_LOCK_AGE=$(( $( date +%s ) - $( date -r $UB_ODHPCD_LOCK +%s ) ))
|
|
||||||
|
|
||||||
if [ $UB_ODHCPD_LOCK_AGE -gt 100 ] ; then
|
|
||||||
# unlock because something likely broke but do not write this time through
|
|
||||||
rm -f $UB_ODHPCD_LOCK
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user