Skip to content

Commit

Permalink
Fix WebLocksMixin.jCheckReservedLock bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
shoestringresearch committed Jun 8, 2024
1 parent 456ca21 commit 304dba3
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/WebLocksMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const WebLocksMixin = superclass => class extends superclass {
return this.#checkReservedExclusive(lockState, pResOut);
case 'shared':
case 'shared+hint':
return await this.#checkReservedShared(lockState, pResOut);
return await this.#checkReservedShared(lockState, pResOut);
}
} catch (e) {
console.error('WebLocksMixin: check reserved lock error', e);
Expand Down Expand Up @@ -151,7 +151,7 @@ export const WebLocksMixin = superclass => class extends superclass {
if (!await this.#acquire(lockState, 'access')) {
return VFS.SQLITE_BUSY;
}
console.assert(lockState.access);
console.assert(!!lockState.access);
}
lockState.type = lockType;
return VFS.SQLITE_OK;
Expand Down Expand Up @@ -210,7 +210,7 @@ export const WebLocksMixin = superclass => class extends superclass {
await this.#acquire(lockState, 'access', SHARED);
lockState.gate();
console.assert(!lockState.gate);
console.assert(lockState.access);
console.assert(!!lockState.access);
console.assert(!lockState.reserved);
break;

Expand Down Expand Up @@ -245,7 +245,7 @@ export const WebLocksMixin = superclass => class extends superclass {
lockState.access();
console.assert(!lockState.gate);
console.assert(!lockState.access);
console.assert(lockState.reserved);
console.assert(!!lockState.reserved);
break;

case VFS.SQLITE_LOCK_EXCLUSIVE:
Expand All @@ -261,8 +261,8 @@ export const WebLocksMixin = superclass => class extends superclass {
lockState.gate();
return VFS.SQLITE_BUSY;
}
console.assert(lockState.gate);
console.assert(lockState.access);
console.assert(!!lockState.gate);
console.assert(!!lockState.access);
console.assert(!lockState.reserved);
break;

Expand All @@ -285,9 +285,9 @@ export const WebLocksMixin = superclass => class extends superclass {
lockState.gate();
return VFS.SQLITE_BUSY;
}
console.assert(lockState.gate);
console.assert(lockState.access);
console.assert(lockState.reserved);
console.assert(!!lockState.gate);
console.assert(!!lockState.access);
console.assert(!!lockState.reserved);
break;

default:
Expand Down Expand Up @@ -330,7 +330,7 @@ export const WebLocksMixin = superclass => class extends superclass {
lockState.gate();
lockState.reserved?.();
lockState.hint?.();
console.assert(lockState.access);
console.assert(!!lockState.access);
console.assert(!lockState.gate);
console.assert(!lockState.reserved);
break;
Expand All @@ -341,7 +341,7 @@ export const WebLocksMixin = superclass => class extends superclass {
await this.#acquire(lockState, 'access', SHARED);
lockState.reserved();
lockState.hint?.();
console.assert(lockState.access);
console.assert(!!lockState.access);
console.assert(!lockState.gate);
console.assert(!lockState.reserved);
break;
Expand All @@ -358,10 +358,11 @@ export const WebLocksMixin = superclass => class extends superclass {
*/
async #checkReservedShared(lockState, pResOut) {
if (await this.#acquire(lockState, 'reserved', POLL_SHARED)) {
// We were able to get the lock so it was not reserved.
lockState.reserved();
pResOut.setInt32(0, 1, true);
} else {
pResOut.setInt32(0, 0, true);
} else {
pResOut.setInt32(0, 1, true);
}
return VFS.SQLITE_OK;
}
Expand Down

0 comments on commit 304dba3

Please sign in to comment.