Internal tweaks to the OPFS VFS result codes.
FossilOrigin-Name: 32e1a2d2eb8738ae1635e413829f6cf7f64c63d2a86b72940a573de89948e529
This commit is contained in:
parent
1acfe91582
commit
43b442a626
@ -316,19 +316,27 @@ const installOpfsVfs = function callee(options){
|
||||
*/
|
||||
state.sq3Codes = Object.create(null);
|
||||
[
|
||||
'SQLITE_ERROR', 'SQLITE_IOERR',
|
||||
'SQLITE_NOTFOUND', 'SQLITE_MISUSE',
|
||||
'SQLITE_IOERR_READ', 'SQLITE_IOERR_SHORT_READ',
|
||||
'SQLITE_IOERR_WRITE', 'SQLITE_IOERR_FSYNC',
|
||||
'SQLITE_IOERR_TRUNCATE', 'SQLITE_IOERR_DELETE',
|
||||
'SQLITE_IOERR_ACCESS', 'SQLITE_IOERR_CLOSE',
|
||||
'SQLITE_ERROR',
|
||||
'SQLITE_IOERR',
|
||||
'SQLITE_IOERR_ACCESS',
|
||||
'SQLITE_IOERR_CLOSE',
|
||||
'SQLITE_IOERR_DELETE',
|
||||
'SQLITE_LOCK_NONE',
|
||||
'SQLITE_LOCK_SHARED',
|
||||
'SQLITE_LOCK_RESERVED',
|
||||
'SQLITE_LOCK_PENDING',
|
||||
'SQLITE_IOERR_FSYNC',
|
||||
'SQLITE_IOERR_LOCK',
|
||||
'SQLITE_IOERR_READ',
|
||||
'SQLITE_IOERR_SHORT_READ',
|
||||
'SQLITE_IOERR_TRUNCATE',
|
||||
'SQLITE_IOERR_UNLOCK',
|
||||
'SQLITE_IOERR_WRITE',
|
||||
'SQLITE_LOCK_EXCLUSIVE',
|
||||
'SQLITE_OPEN_CREATE', 'SQLITE_OPEN_DELETEONCLOSE',
|
||||
'SQLITE_LOCK_NONE',
|
||||
'SQLITE_LOCK_PENDING',
|
||||
'SQLITE_LOCK_RESERVED',
|
||||
'SQLITE_LOCK_SHARED',
|
||||
'SQLITE_MISUSE',
|
||||
'SQLITE_NOTFOUND',
|
||||
'SQLITE_OPEN_CREATE',
|
||||
'SQLITE_OPEN_DELETEONCLOSE',
|
||||
'SQLITE_OPEN_READONLY'
|
||||
].forEach((k)=>{
|
||||
if(undefined === (state.sq3Codes[k] = capi[k])){
|
||||
|
@ -135,6 +135,25 @@ const getDirForFilename = async function f(absFilename, createDirs = false){
|
||||
return [dh, filename];
|
||||
};
|
||||
|
||||
/**
|
||||
An error class specifically for use with getSyncHandle(), the goal
|
||||
of which is to eventually be able to distinguish unambiguously
|
||||
between locking-related failures and other types, noting that we
|
||||
cannot currently do so because createSyncAccessHandle() does not
|
||||
define its exceptions in the required level of detail.
|
||||
*/
|
||||
class GetSyncHandleError extends Error {
|
||||
constructor(errorObject, ...msg){
|
||||
super();
|
||||
this.error = errorObject;
|
||||
this.message = [
|
||||
...msg, ': Original exception ['+errorObject.name+']:',
|
||||
errorObject.message
|
||||
].join(' ');
|
||||
this.name = 'GetSyncHandleError';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the sync access handle associated with the given file
|
||||
handle object (which must be a valid handle object, as created by
|
||||
@ -154,16 +173,17 @@ const getSyncHandle = async (fh)=>{
|
||||
let i = 1, ms = msBase;
|
||||
for(; true; ms = msBase * ++i){
|
||||
try {
|
||||
//if(i<3) toss("Just testing.");
|
||||
//if(i<3) toss("Just testing getSyncHandle() wait-and-retry.");
|
||||
//TODO? A config option which tells it to throw here
|
||||
//randomly every now and then, for testing purposes.
|
||||
fh.syncHandle = await fh.fileHandle.createSyncAccessHandle();
|
||||
break;
|
||||
}catch(e){
|
||||
if(i === maxTries){
|
||||
toss("Error getting sync handle.",maxTries,
|
||||
"attempts failed. ",fh.filenameAbs, ":", e.message);
|
||||
throw e;
|
||||
throw new GetSyncHandleError(
|
||||
e, "Error getting sync handle.",maxTries,
|
||||
"attempts failed.",fh.filenameAbs
|
||||
);
|
||||
}
|
||||
warn("Error getting sync handle. Waiting",ms,
|
||||
"ms and trying again.",fh.filenameAbs,e);
|
||||
@ -199,7 +219,7 @@ const closeSyncHandle = async (fh)=>{
|
||||
Atomics.notify()'s it.
|
||||
*/
|
||||
const storeAndNotify = (opName, value)=>{
|
||||
log(opName+"() => notify(",state.opIds.rc,",",value,")");
|
||||
log(opName+"() => notify(",value,")");
|
||||
Atomics.store(state.sabOPView, state.opIds.rc, value);
|
||||
Atomics.notify(state.sabOPView, state.opIds.rc);
|
||||
};
|
||||
@ -371,18 +391,18 @@ const vfsAsyncImpls = {
|
||||
xFileSize: async function(fid/*sqlite3_file pointer*/){
|
||||
mTimeStart('xFileSize');
|
||||
const fh = __openFiles[fid];
|
||||
let sz;
|
||||
let rc;
|
||||
wTimeStart('xFileSize');
|
||||
try{
|
||||
sz = await (await getSyncHandle(fh)).getSize();
|
||||
state.s11n.serialize(Number(sz));
|
||||
sz = 0;
|
||||
rc = await (await getSyncHandle(fh)).getSize();
|
||||
state.s11n.serialize(Number(rc));
|
||||
rc = 0;
|
||||
}catch(e){
|
||||
state.s11n.storeException(2,e);
|
||||
sz = state.sq3Codes.SQLITE_IOERR;
|
||||
rc = state.sq3Codes.SQLITE_IOERR;
|
||||
}
|
||||
wTimeEnd();
|
||||
storeAndNotify('xFileSize', sz);
|
||||
storeAndNotify('xFileSize', rc);
|
||||
mTimeEnd();
|
||||
},
|
||||
xLock: async function(fid/*sqlite3_file pointer*/,
|
||||
@ -395,7 +415,7 @@ const vfsAsyncImpls = {
|
||||
try { await getSyncHandle(fh) }
|
||||
catch(e){
|
||||
state.s11n.storeException(1,e);
|
||||
rc = state.sq3Codes.SQLITE_IOERR;
|
||||
rc = state.sq3Codes.SQLITE_IOERR_LOCK;
|
||||
}
|
||||
wTimeEnd();
|
||||
}
|
||||
@ -480,6 +500,7 @@ const vfsAsyncImpls = {
|
||||
await fh.syncHandle.flush();
|
||||
}catch(e){
|
||||
state.s11n.storeException(2,e);
|
||||
rc = state.sq3Codes.SQLITE_IOERR_FSYNC;
|
||||
}
|
||||
wTimeEnd();
|
||||
}
|
||||
@ -514,7 +535,7 @@ const vfsAsyncImpls = {
|
||||
try { await closeSyncHandle(fh) }
|
||||
catch(e){
|
||||
state.s11n.storeException(1,e);
|
||||
rc = state.sq3Codes.SQLITE_IOERR;
|
||||
rc = state.sq3Codes.SQLITE_IOERR_UNLOCK;
|
||||
}
|
||||
wTimeEnd();
|
||||
}
|
||||
@ -641,7 +662,7 @@ const initS11n = ()=>{
|
||||
state.s11n.storeException = state.asyncS11nExceptions
|
||||
? ((priority,e)=>{
|
||||
if(priority<=state.asyncS11nExceptions){
|
||||
state.s11n.serialize(e.message);
|
||||
state.s11n.serialize([e.name,': ',e.message].join(''));
|
||||
}
|
||||
})
|
||||
: ()=>{};
|
||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Add\soo1.DB.exec()\s'returnValue'\soption,\swhich\sspecifies\swhat\sexec()\sshould\sreturn.\sDefaults\sto\sthe\sdb\sobject\sand\senables\sdirect\sreturn\sof\sthe\sresult\srows\sarray\sor\sa\slist\sof\sthe\sindividual\sSQL\sstatements.\sOther\scode-adjacent\sinternal\scleanups.
|
||||
D 2022-10-31T11:09:14.111
|
||||
C Internal\stweaks\sto\sthe\sOPFS\sVFS\sresult\scodes.
|
||||
D 2022-10-31T11:53:34.287
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -501,11 +501,11 @@ F ext/wasm/api/pre-js.js 287e462f969342b032c03900e668099fa1471d852df7a472de5bc34
|
||||
F ext/wasm/api/sqlite3-api-cleanup.js ecdc69dbfccfe26146f04799fcfd4a6f5790d46e7e3b9b6e9b0491f92ed8ae34
|
||||
F ext/wasm/api/sqlite3-api-glue.js b87543534821ecfa56fc0d0cd153a115fa974e70d6217964baf6e93ef8d25fb1
|
||||
F ext/wasm/api/sqlite3-api-oo1.js 4028bc2bac7e3ae2d23b7c99828155b4a06da006b51dc2a929bc0db26337370d
|
||||
F ext/wasm/api/sqlite3-api-opfs.js c67cbe0b1451ec43bc6b3199e13453e1ca56d718a75c0498253b0d479c336256
|
||||
F ext/wasm/api/sqlite3-api-opfs.js 6880cc79a4d1b6075942298d9d1ab07e24d81fbd9e5fe6b7c797b86e4b2af596
|
||||
F ext/wasm/api/sqlite3-api-prologue.js 873986ca150c79510f647b910f8349bc71b14db21e444cab3b9fad9c4f39ffc7
|
||||
F ext/wasm/api/sqlite3-api-worker1.js efdca1b42299d80b54f366d15a8fc5343f3b3e9e3647e5c1fd6f3ee1015e501b
|
||||
F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
|
||||
F ext/wasm/api/sqlite3-opfs-async-proxy.js 29f6f5c314c2956e77573c6ab975c2455a0839721ed44f38004382c2a1463ab5
|
||||
F ext/wasm/api/sqlite3-opfs-async-proxy.js b2264efef84c4a0af5dab426d7573d8b4ee5af3a25ba108b709a835a613c5e36
|
||||
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
|
||||
F ext/wasm/api/sqlite3-wasm.c 14ac9c03f6585332f882703f3427f11ffe8ffe8b6c0e252be2c518f7aac6ab6a
|
||||
F ext/wasm/api/sqlite3-worker1-promiser.js 0c7a9826dbf82a5ed4e4f7bf7816e825a52aff253afbf3350431f5773faf0e4b
|
||||
@ -2054,8 +2054,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P e02c697281a777c33070168af784b2d291397e488244a217620897f40aed7158
|
||||
R 26339704ab975fcc1e6818338a87c2a1
|
||||
P 69d36a6aa5e2cd79d26c0fd3e0d20fe8838fd1be97db07725233bfff1dfe6643
|
||||
R a5a69989c955a2bef03fc5f6b9426b6e
|
||||
U stephan
|
||||
Z 2aa3561d4216c084633673f53cc5adc1
|
||||
Z 2e8ea5a9464277cec17ca6c43e6fd2fa
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
69d36a6aa5e2cd79d26c0fd3e0d20fe8838fd1be97db07725233bfff1dfe6643
|
||||
32e1a2d2eb8738ae1635e413829f6cf7f64c63d2a86b72940a573de89948e529
|
Loading…
x
Reference in New Issue
Block a user