From 4269bc9548ecbbd8d0b1fd8dfcfa590175dd3a30 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sun, 25 Jul 2021 23:08:23 +0200 Subject: global-functions: $ScriptLock: check for successful removal of ticket The script is already locked, so there is no second script to remove a ticket at the same time. However a new script can add a new ticket and overwrite the removal... Thus check for successful removal anyway. --- global-functions | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/global-functions b/global-functions index 7a0bb39..bbea143 100644 --- a/global-functions +++ b/global-functions @@ -946,13 +946,17 @@ :global ScriptLockOrder; - :local New [ :toarray "" ]; - :foreach Ticket in=($ScriptLockOrder->$Script) do={ - :if ($Ticket != $Remove) do={ - :set New ($New, $Ticket); + :while (true) do={ + :local New [ :toarray "" ]; + :foreach Ticket in=($ScriptLockOrder->$Script) do={ + :if ($Ticket != $Remove) do={ + :set New ($New, $Ticket); + } } + :set ($ScriptLockOrder->$Script) $New; + :delay 12ms; + :if (($ScriptLockOrder->$Script->0) != $Remove) do={ :return true; } } - :set ($ScriptLockOrder->$Script) $New; } :if ([ :len [ / system script find where name=$Script ] ] = 0) do={ -- cgit v1.2.3-70-g09d2