Ensure unique transaction IDs

Long overdue :)
This commit is contained in:
Juerd Waalboer 2022-10-31 19:00:20 +01:00
parent 44d17e6ae0
commit 922f8dc8f6
2 changed files with 6 additions and 4 deletions

View file

@ -24,13 +24,15 @@ sub get_lock() {
open $lockfh, ">", $lockfn;
my $attempt = 1;
my $debug = !!$ENV{REVBANK_DEBUG};
FLOCK: {
if (flock $lockfh, LOCK_EX | LOCK_NB) {
syswrite $lockfh, $$;
return ++$lockcount;
}
if (($attempt % 50) == 0) {
if (($attempt % 50) == 0 or $debug) {
warn "Another revbank instance has the global lock. Waiting for it to finish...\n"
}
sleep .1;