*/
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_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_LOCK_NONE',
- 'SQLITE_LOCK_SHARED',
- 'SQLITE_LOCK_RESERVED',
'SQLITE_LOCK_PENDING',
- 'SQLITE_LOCK_EXCLUSIVE',
- 'SQLITE_OPEN_CREATE', 'SQLITE_OPEN_DELETEONCLOSE',
+ '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])){
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
let i = 1, ms = msBase;
for(; true; ms = msBase * ++i){
try {
- //if(i<3) toss("Just testing.");
+ //if(1 || i<2) toss("Just testing getSyncHandle() exception handling.");
//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);
Atomics.notify()'s it.
*/
const storeAndNotify = (opName, value)=>{
- log(opName+"() => notify(",state.opIds.rc,",",value,")");
+ log(opName+"() => notify( rc =",value,")");
Atomics.store(state.sabOPView, state.opIds.rc, value);
Atomics.notify(state.sabOPView, state.opIds.rc);
};
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 = (e instanceof GetSyncHandleError)
+ ? state.sq3Codes.SQLITE_IOERR_LOCK
+ : state.sq3Codes.SQLITE_IOERR;
}
wTimeEnd();
- storeAndNotify('xFileSize', sz);
+ storeAndNotify('xFileSize', rc);
mTimeEnd();
},
xLock: async function(fid/*sqlite3_file pointer*/,
try { await getSyncHandle(fh) }
catch(e){
state.s11n.storeException(1,e);
- rc = state.sq3Codes.SQLITE_IOERR;
+ rc = (e instanceof GetSyncHandleError)
+ ? state.sq3Codes.SQLITE_IOERR_LOCK
+ : state.sq3Codes.SQLITE_IOERR;
}
wTimeEnd();
}
if(undefined===nRead) wTimeEnd();
error("xRead() failed",e,fh);
state.s11n.storeException(1,e);
- rc = state.sq3Codes.SQLITE_IOERR_READ;
+ rc = (e instanceof GetSyncHandleError)
+ ? state.sq3Codes.SQLITE_IOERR_LOCK
+ : state.sq3Codes.SQLITE_IOERR_READ;
}
storeAndNotify('xRead',rc);
mTimeEnd();
await fh.syncHandle.flush();
}catch(e){
state.s11n.storeException(2,e);
+ rc = state.sq3Codes.SQLITE_IOERR_FSYNC;
}
wTimeEnd();
}
}catch(e){
error("xTruncate():",e,fh);
state.s11n.storeException(2,e);
- rc = state.sq3Codes.SQLITE_IOERR_TRUNCATE;
+ rc = (e instanceof GetSyncHandleError)
+ ? state.sq3Codes.SQLITE_IOERR_LOCK
+ : state.sq3Codes.SQLITE_IOERR_TRUNCATE;
}
wTimeEnd();
storeAndNotify('xTruncate',rc);
try { await closeSyncHandle(fh) }
catch(e){
state.s11n.storeException(1,e);
- rc = state.sq3Codes.SQLITE_IOERR;
+ rc = state.sq3Codes.SQLITE_IOERR_UNLOCK;
}
wTimeEnd();
}
}catch(e){
error("xWrite():",e,fh);
state.s11n.storeException(1,e);
- rc = state.sq3Codes.SQLITE_IOERR_WRITE;
+ rc = (e instanceof GetSyncHandleError)
+ ? state.sq3Codes.SQLITE_IOERR_LOCK
+ : state.sq3Codes.SQLITE_IOERR_WRITE;
}
wTimeEnd();
storeAndNotify('xWrite',rc);
state.s11n.storeException = state.asyncS11nExceptions
? ((priority,e)=>{
if(priority<=state.asyncS11nExceptions){
- state.s11n.serialize(e.message);
+ state.s11n.serialize([e.name,': ',e.message].join(''));
}
})
: ()=>{};
-C Adjust\sautomatic\sOPFS\slocking\sretries\ssuch\sthat\sthey\swill\swait\sup\sto\sa\stotal\sof\s3\sseconds\sspanning\s4\sattempts.
-D 2022-10-30T10:24:53.526
+C Refactoring\stowards\sbeing\sable\sto\sdistinguish\slocking-related\serrors\sfrom\snon-locking\serrors\sin\sOPFS\sVFS\soperations.\sOn\sa\sbranch\sbecause\sit's\snot\syet\sclear\swhether\sthis\sis\sa\smisuse\sof\sthe\sSQLITE_IOERR_...\scodes.
+D 2022-10-30T11:22:45.699
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
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 612063da9838286310712c5411f97b8b20759b1e31e75a9b25b6381541db79a8
-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 a218dda5e5ced8894f65760131371e4cabd31062af58803af8952cc00ea778d2
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 08acf5cf128f784375776af23b35de6dbdf65cf50928e1131f2748abeebce12e
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
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 50f678846a2b3c3d0818f0bae89f2ee86252a2e6a9c7029ebaae3953ca0fa14c
-R 1972183d0891a999ac8d66d2a75ace56
+P bbce49d81abc491ca666474040a53057e26e99131fea9449de253f88f4415ded
+R 2221e9c9fd283b544621efdb3f1e68c6
+T *branch * opfs-locking-result-codes
+T *sym-opfs-locking-result-codes *
+T -sym-trunk * Cancelled\sby\sbranch.
U stephan
-Z d56b11be64ada51bbacb5dad8807cd55
+Z dbd1acd209f3424e033d21c8b6f257fa
# Remove this line to create a well-formed Fossil manifest.