Skip to content

Commit

Permalink
fix: Avoid some dead locks during installing instance
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Mar 29, 2024
1 parent 9ae9008 commit 525ffcd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions xmcl-runtime-api/src/util/mutex.ts
Expand Up @@ -34,10 +34,14 @@ export class ReadWriteLock {
private async processIfIdle() {
if (this.status === LockStatus.Idle) {
while (this.queue.length > 0) {
const [operation, release] = this.queue.shift()!
this.release = release
this.status = release ? LockStatus.Reading : LockStatus.Writing
await operation()
try {
const [operation, release] = this.queue.shift()!
this.release = release
this.status = release ? LockStatus.Reading : LockStatus.Writing
await operation()
} catch {
// no-op
}
}
this.status = LockStatus.Idle
}
Expand Down

0 comments on commit 525ffcd

Please sign in to comment.