mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Adjust the previous check-in to replace the db's WASM address with yet another random number, and increase the range of random numbers, reducing the chance of cross-worker db ID collision to 1 in many billions.
FossilOrigin-Name: f5e2a72c57e802c5042ab8343e5009ba9f22ca7138a1c78f4b8201ab9b4fd395
This commit is contained in:
@@ -385,8 +385,9 @@ sqlite3.initWorker1API = function(){
|
||||
const getDbId = function(db){
|
||||
let id = wState.idMap.get(db);
|
||||
if(id) return id;
|
||||
id = 'db#'+(++wState.idSeq)+'@'+db.pointer+':'+
|
||||
Math.floor(Math.random() * 10000000);
|
||||
id = 'db#'+(++wState.idSeq)+':'+
|
||||
Math.floor(Math.random() * 100000000)+':'+
|
||||
Math.floor(Math.random() * 100000000);
|
||||
/** ^^^ can't simply use db.pointer b/c closing/opening may re-use
|
||||
the same address, which could map pending messages to a wrong
|
||||
instance.
|
||||
|
||||
Reference in New Issue
Block a user