Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WebLocksMixin implementation of xCheckReservedLock #182

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions karma.conf.cjs

This file was deleted.

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
Loading