taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 5f00bcf20b16940f6761a9ec58117ea7ff665ada
parent d983ff060560c0e0807020047676d46d97077cc3
Author: Florian Dold <dold@taler.net>
Date:   Thu,  3 Sep 2026 15:47:37 +0200

wallet-core: hand a released lock straight to its waiter

Deleting the lock before resuming the waiter left a window in which a
newcomer could take it, so two callers ran the sections around the
melt and pay requests at once.

Diffstat:
Mpackages/taler-wallet-core/src/sequential-locks.ts | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/packages/taler-wallet-core/src/sequential-locks.ts b/packages/taler-wallet-core/src/sequential-locks.ts @@ -39,19 +39,25 @@ export class SequentialLocks { waitList = this.waiters[token] = []; } waitList.push(p); + // The holder passes the lock on when it resolves us, so it is + // already ours once we resume. await p.promise; + } else { + this.locks.add(token); } - this.locks.add(token); } try { return await f(); } finally { for (const token of tokens) { - this.locks.delete(token); const waiter = (this.waiters[token] ?? []).shift(); if (waiter) { + // Ownership moves to the waiter without the lock ever being free, + // so nobody else can slip in before the waiter resumes. waiter.resolve(); + } else { + this.locks.delete(token); } } }