From 84f20951b32b8652c3fce37c23d795583718ac84 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Thu, 26 Nov 2020 22:39:15 +0100 Subject: [PATCH] travelmate: fix possible race condition * prevent possible duplicate script execution due to multiple ntp events in parallel Signed-off-by: Dirk Brenken --- net/travelmate/Makefile | 2 +- net/travelmate/files/travelmate_ntp.hotplug | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/net/travelmate/Makefile b/net/travelmate/Makefile index 1f9935466c..c74a33a081 100644 --- a/net/travelmate/Makefile +++ b/net/travelmate/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=travelmate PKG_VERSION:=2.0.2 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/travelmate/files/travelmate_ntp.hotplug b/net/travelmate/files/travelmate_ntp.hotplug index 4a31d59467..2a215e4ba4 100755 --- a/net/travelmate/files/travelmate_ntp.hotplug +++ b/net/travelmate/files/travelmate_ntp.hotplug @@ -22,10 +22,14 @@ f_log() fi } -if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && \ - [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ] +if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ] then - > "${trm_ntpfile}" - f_log "info" "get ntp time sync" - "${trm_init}" restart + { + flock -xn 1001 + if [ "$?" = "0" ] + then + f_log "info" "get ntp time sync" + "${trm_init}" restart + fi + } 1001>"${trm_ntpfile}" fi -- 2.30.2