From 6089e212dc038dbd43f67a41c7dc389f6f20bb45 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Mon, 16 Jan 2023 01:17:33 +0100 Subject: [PATCH] Release locks on abort Fixes deadlock if hook_checkout returns ABORT. One of these days I want to implement the abort mechanism through exceptions, even though that means handling it explicitly in more places. Or maybe *because* that means handling it explicitly in more places. --- lib/RevBank/FileIO.pm | 4 ++++ revbank | 1 + 2 files changed, 5 insertions(+) diff --git a/lib/RevBank/FileIO.pm b/lib/RevBank/FileIO.pm index 32b4f1a..a54412c 100644 --- a/lib/RevBank/FileIO.pm +++ b/lib/RevBank/FileIO.pm @@ -60,6 +60,10 @@ sub release_lock() { } } +sub release_all_locks() { + release_lock while $lockcount; +} + sub with_lock :prototype(&) ($code) { get_lock; my @rv; diff --git a/revbank b/revbank index ed42a2a..869cfd0 100755 --- a/revbank +++ b/revbank @@ -143,6 +143,7 @@ OUTER: for (;;) { @retry = (); call_hooks "abort", $cart, \@_; $cart->empty; + RevBank::FileIO::release_all_locks; { no warnings; redo OUTER; } }