From 9509371690c26bb67918448458f7b2989df4635c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jul 2021 11:45:35 +0200 Subject: [PATCH] lease-script: use $ScriptLock There were still ways to produce errors from lease scripts... Let's lock earlier, this should fix it. --- lease-script | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lease-script b/lease-script index 44360a4..3134cb6 100644 --- a/lease-script +++ b/lease-script @@ -13,6 +13,7 @@ :global IfThenElse; :global LogPrintExit2; :global ParseKeyValueStore; +:global ScriptLock; :if ([ :typeof $leaseActIP ] = "nothing" || \ [ :typeof $leaseActMAC ] = "nothing" || \ @@ -21,6 +22,12 @@ $LogPrintExit2 error $0 ("This script is supposed to run from ip dhcp-server.") true; } +$ScriptLock $0 false 10; + +:if ([ :len [ / system script job find where script=$0 ] ] > 1) do={ + $LogPrintExit2 debug $0 ("More invocations are waiting, exiting early.") true; +} + :local State ([ $IfThenElse ($leaseBound = 0) "de" "" ] . "assign"); :local RunOrder [ :toarray "" ]; @@ -41,12 +48,10 @@ $LogPrintExit2 debug $0 ("DHCP Server " . $leaseServerName . " " . \ } :foreach Order,Script in=$RunOrder do={ - :if ([ :len [ / system script job find where script=$Script ] ] < 2) do={ - :do { - $LogPrintExit2 debug $0 ("Running script with order " . $Order . ": " . $Script) false; - / system script run $Script; - } on-error={ - $LogPrintExit2 warning $0 ("Running script '" . $Script . "' failed!") false; - } + :do { + $LogPrintExit2 debug $0 ("Running script with order " . $Order . ": " . $Script) false; + / system script run $Script; + } on-error={ + $LogPrintExit2 warning $0 ("Running script '" . $Script . "' failed!") false; } }