@ai-ecoverse/slicc-kernel 1.191.4 → 1.192.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +298 -224
- package/dist/cloudflare.js.map +4 -4
- package/dist/driver-worker.js +1 -1
- package/dist/driver-worker.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +251 -191
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +1 -1
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +259 -199
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/cdp/held.d.ts +7 -0
- package/dist/types/cloudflare/options.d.ts +2 -0
- package/dist/types/cloudflare.d.ts +1 -0
- package/package.json +7 -7
package/dist/kernel-worker.js
CHANGED
|
@@ -1150,11 +1150,11 @@ var ProtectedFs = class {
|
|
|
1150
1150
|
async exclusive(path, run2, follow2) {
|
|
1151
1151
|
return fs.exclusive(
|
|
1152
1152
|
path,
|
|
1153
|
-
(
|
|
1154
|
-
...
|
|
1153
|
+
(held2) => run2({
|
|
1154
|
+
...held2,
|
|
1155
1155
|
writeFile: async (...args) => {
|
|
1156
1156
|
await check(args[0], true);
|
|
1157
|
-
return
|
|
1157
|
+
return held2.writeFile(...args);
|
|
1158
1158
|
}
|
|
1159
1159
|
}),
|
|
1160
1160
|
follow2
|
|
@@ -1250,8 +1250,8 @@ var RemoteWatch = class {
|
|
|
1250
1250
|
if (!this.locks) return;
|
|
1251
1251
|
const prefix = `${this.name}:`;
|
|
1252
1252
|
const mine = this.lockOf(this.tab);
|
|
1253
|
-
const
|
|
1254
|
-
if (!
|
|
1253
|
+
const held2 = ((await this.locks.query()).held ?? []).map((lock) => lock.name ?? "");
|
|
1254
|
+
if (!held2.some((name2) => name2.startsWith(prefix) && name2 !== mine) || this.peers.size > 0)
|
|
1255
1255
|
return;
|
|
1256
1256
|
await new Promise((resolve2) => {
|
|
1257
1257
|
const timer = setTimeout(resolve2, ANNOUNCE_WAIT_MS);
|
|
@@ -1285,8 +1285,8 @@ var RemoteWatch = class {
|
|
|
1285
1285
|
const prefix = `${this.name}:`;
|
|
1286
1286
|
const began = performance.now();
|
|
1287
1287
|
for (; ; ) {
|
|
1288
|
-
const
|
|
1289
|
-
const silent =
|
|
1288
|
+
const held2 = ((await this.locks.query()).held ?? []).map((lock) => lock.name ?? "");
|
|
1289
|
+
const silent = held2.some(
|
|
1290
1290
|
(name2) => name2.startsWith(prefix) && name2 !== this.lockOf(this.tab) && !this.peers.has(name2.slice(prefix.length))
|
|
1291
1291
|
);
|
|
1292
1292
|
if (!silent) return true;
|
|
@@ -1336,8 +1336,8 @@ var RemoteWatch = class {
|
|
|
1336
1336
|
if (!this.locks || this.mourned.has(peer)) return;
|
|
1337
1337
|
this.mourned.add(peer);
|
|
1338
1338
|
const name2 = this.lockOf(peer);
|
|
1339
|
-
const { held = [], pending = [] } = await this.locks.query();
|
|
1340
|
-
if (![...
|
|
1339
|
+
const { held: held2 = [], pending = [] } = await this.locks.query();
|
|
1340
|
+
if (![...held2, ...pending].some((lock) => lock.name === name2)) {
|
|
1341
1341
|
this.mourned.delete(peer);
|
|
1342
1342
|
const live2 = this.peers.has(peer) || this.flushes.has(peer);
|
|
1343
1343
|
if (tries > 1 && live2) {
|
|
@@ -1418,10 +1418,10 @@ var RemoteWatch = class {
|
|
|
1418
1418
|
const from = tab;
|
|
1419
1419
|
const { add, drop } = holds3;
|
|
1420
1420
|
if (holds3?.instance !== void 0) this.instances.set(from, holds3.instance);
|
|
1421
|
-
const
|
|
1422
|
-
for (const path of drop)
|
|
1423
|
-
for (const [path, fid] of add)
|
|
1424
|
-
if (
|
|
1421
|
+
const held2 = this.peerHolds.get(from) ?? /* @__PURE__ */ new Map();
|
|
1422
|
+
for (const path of drop) held2.delete(path);
|
|
1423
|
+
for (const [path, fid] of add) held2.set(path, fid);
|
|
1424
|
+
if (held2.size > 0) this.peerHolds.set(from, held2);
|
|
1425
1425
|
else this.peerHolds.delete(from);
|
|
1426
1426
|
this.holdsChanged?.();
|
|
1427
1427
|
this.channel.postMessage({ ack: seq2, from: this.tab, to: from });
|
|
@@ -1470,8 +1470,8 @@ var RemoteWatch = class {
|
|
|
1470
1470
|
}
|
|
1471
1471
|
heldWithin(target) {
|
|
1472
1472
|
const out = [];
|
|
1473
|
-
for (const [tab,
|
|
1474
|
-
for (const [path, fid] of
|
|
1473
|
+
for (const [tab, held2] of this.peerHolds) {
|
|
1474
|
+
for (const [path, fid] of held2) {
|
|
1475
1475
|
if (path !== target && !path.startsWith(`${target}/`)) continue;
|
|
1476
1476
|
out.push({ tab, path, fid, instance: this.instances.get(tab) });
|
|
1477
1477
|
}
|
|
@@ -1495,18 +1495,18 @@ var RemoteWatch = class {
|
|
|
1495
1495
|
}
|
|
1496
1496
|
peerHeld(path) {
|
|
1497
1497
|
const out = [];
|
|
1498
|
-
for (const [tab,
|
|
1499
|
-
if (
|
|
1498
|
+
for (const [tab, held2] of this.peerHolds)
|
|
1499
|
+
if (held2.has(path)) out.push({ tab, fid: held2.get(path) });
|
|
1500
1500
|
return out;
|
|
1501
1501
|
}
|
|
1502
1502
|
peerHeldPaths() {
|
|
1503
1503
|
const out = /* @__PURE__ */ new Set();
|
|
1504
|
-
for (const
|
|
1504
|
+
for (const held2 of this.peerHolds.values()) for (const path of held2.keys()) out.add(path);
|
|
1505
1505
|
return [...out].sort();
|
|
1506
1506
|
}
|
|
1507
1507
|
holdCounts() {
|
|
1508
1508
|
let peers = 0;
|
|
1509
|
-
for (const
|
|
1509
|
+
for (const held2 of this.peerHolds.values()) peers += held2.size;
|
|
1510
1510
|
return { mine: this.myHolds.size, peers, sent: this.holdsSent };
|
|
1511
1511
|
}
|
|
1512
1512
|
acked(seq2, from) {
|
|
@@ -1521,10 +1521,10 @@ var RemoteWatch = class {
|
|
|
1521
1521
|
}
|
|
1522
1522
|
async prune() {
|
|
1523
1523
|
if (!this.locks) return;
|
|
1524
|
-
const
|
|
1524
|
+
const held2 = new Set(((await this.locks.query()).held ?? []).map((lock) => lock.name));
|
|
1525
1525
|
let left = false;
|
|
1526
1526
|
for (const tab of /* @__PURE__ */ new Set([...this.others.keys(), ...this.peers, ...this.peerHolds.keys()])) {
|
|
1527
|
-
if (!
|
|
1527
|
+
if (!held2.has(this.lockOf(tab))) {
|
|
1528
1528
|
if (this.peers.delete(tab)) left = true;
|
|
1529
1529
|
this.others.delete(tab);
|
|
1530
1530
|
if (this.peerHolds.delete(tab)) this.holdsChanged?.();
|
|
@@ -1989,14 +1989,14 @@ var OpfsFs = class {
|
|
|
1989
1989
|
return void 0;
|
|
1990
1990
|
}
|
|
1991
1991
|
heldUnder = () => [];
|
|
1992
|
-
heldBy(
|
|
1993
|
-
this.heldUnder =
|
|
1992
|
+
heldBy(held2) {
|
|
1993
|
+
this.heldUnder = held2;
|
|
1994
1994
|
}
|
|
1995
1995
|
async pinHeld(dir) {
|
|
1996
|
-
const
|
|
1997
|
-
if (
|
|
1998
|
-
const known = await this.meta.get(
|
|
1999
|
-
const bare =
|
|
1996
|
+
const held2 = this.heldUnder(dir);
|
|
1997
|
+
if (held2.length === 0) return;
|
|
1998
|
+
const known = await this.meta.get(held2);
|
|
1999
|
+
const bare = held2.filter((_, i) => known[i]?.ino === void 0);
|
|
2000
2000
|
for (const p of bare) {
|
|
2001
2001
|
await this.meta.update(p, (entry) => ({ ...occupied(entry), path: p, ino: inodeOf(p) }));
|
|
2002
2002
|
}
|
|
@@ -3436,8 +3436,8 @@ var OpfsFs = class {
|
|
|
3436
3436
|
}
|
|
3437
3437
|
}
|
|
3438
3438
|
async renamingElsewhere() {
|
|
3439
|
-
const { held = [] } = await this.locks.query();
|
|
3440
|
-
return
|
|
3439
|
+
const { held: held2 = [] } = await this.locks.query();
|
|
3440
|
+
return held2.some(({ name: name2 }) => this.renameHere(name2) && !this.ownLocks.has(name2));
|
|
3441
3441
|
}
|
|
3442
3442
|
lookForRenames() {
|
|
3443
3443
|
const locks = this.locks;
|
|
@@ -3447,8 +3447,8 @@ var OpfsFs = class {
|
|
|
3447
3447
|
for (; ; ) {
|
|
3448
3448
|
const asked = performance.now();
|
|
3449
3449
|
this.queries++;
|
|
3450
|
-
const { held = [] } = await locks.query();
|
|
3451
|
-
const unknown = () =>
|
|
3450
|
+
const { held: held2 = [] } = await locks.query();
|
|
3451
|
+
const unknown = () => held2.some(
|
|
3452
3452
|
({ name: name2 }) => this.renameHere(name2) && !this.ownLocks.has(name2) && !this.peerMoves.has(name2)
|
|
3453
3453
|
);
|
|
3454
3454
|
if (unknown()) await this.learnRenames();
|
|
@@ -3629,13 +3629,13 @@ var OpfsFs = class {
|
|
|
3629
3629
|
}
|
|
3630
3630
|
async finishRenames(orphaned = false) {
|
|
3631
3631
|
const locks = this.locks;
|
|
3632
|
-
const
|
|
3632
|
+
const held2 = /* @__PURE__ */ new Set();
|
|
3633
3633
|
if (orphaned && locks) {
|
|
3634
3634
|
const { held: h = [], pending = [] } = await locks.query();
|
|
3635
|
-
for (const lock of [...h, ...pending])
|
|
3635
|
+
for (const lock of [...h, ...pending]) held2.add(lock.name);
|
|
3636
3636
|
}
|
|
3637
3637
|
const intents = (await this.meta.under(RENAMES2)).filter(
|
|
3638
|
-
(entry) => entry.rename !== void 0 && (!orphaned || locks !== void 0 && entry.rename.lock !== void 0 && !
|
|
3638
|
+
(entry) => entry.rename !== void 0 && (!orphaned || locks !== void 0 && entry.rename.lock !== void 0 && !held2.has(entry.rename.lock))
|
|
3639
3639
|
).sort(
|
|
3640
3640
|
(a, b) => a.rename.at - b.rename.at
|
|
3641
3641
|
);
|
|
@@ -4962,6 +4962,56 @@ function enableCdp(net, hosts) {
|
|
|
4962
4962
|
return () => facade;
|
|
4963
4963
|
}
|
|
4964
4964
|
|
|
4965
|
+
// src/cdp/held.ts
|
|
4966
|
+
function heldConnection(send2, close) {
|
|
4967
|
+
const queued = [];
|
|
4968
|
+
let ended;
|
|
4969
|
+
let onmessage = null;
|
|
4970
|
+
let onclose = null;
|
|
4971
|
+
let draining = false;
|
|
4972
|
+
const drain2 = () => {
|
|
4973
|
+
if (draining) return;
|
|
4974
|
+
draining = true;
|
|
4975
|
+
queueMicrotask(() => {
|
|
4976
|
+
draining = false;
|
|
4977
|
+
while (onmessage && queued.length > 0) onmessage(queued.shift());
|
|
4978
|
+
if (!onclose || !ended) return;
|
|
4979
|
+
const { reason } = ended;
|
|
4980
|
+
ended = void 0;
|
|
4981
|
+
onclose(reason);
|
|
4982
|
+
});
|
|
4983
|
+
};
|
|
4984
|
+
const conn = {
|
|
4985
|
+
send: send2,
|
|
4986
|
+
close,
|
|
4987
|
+
get onmessage() {
|
|
4988
|
+
return onmessage;
|
|
4989
|
+
},
|
|
4990
|
+
set onmessage(next3) {
|
|
4991
|
+
onmessage = next3;
|
|
4992
|
+
if (next3) drain2();
|
|
4993
|
+
},
|
|
4994
|
+
get onclose() {
|
|
4995
|
+
return onclose;
|
|
4996
|
+
},
|
|
4997
|
+
set onclose(next3) {
|
|
4998
|
+
onclose = next3;
|
|
4999
|
+
if (next3) drain2();
|
|
5000
|
+
}
|
|
5001
|
+
};
|
|
5002
|
+
return {
|
|
5003
|
+
conn,
|
|
5004
|
+
message(message3) {
|
|
5005
|
+
if (onmessage && queued.length === 0) onmessage(message3);
|
|
5006
|
+
else queued.push(message3);
|
|
5007
|
+
},
|
|
5008
|
+
end(reason) {
|
|
5009
|
+
ended = { reason };
|
|
5010
|
+
drain2();
|
|
5011
|
+
}
|
|
5012
|
+
};
|
|
5013
|
+
}
|
|
5014
|
+
|
|
4965
5015
|
// src/cdp/hosts.ts
|
|
4966
5016
|
var CdpHosts = class {
|
|
4967
5017
|
embedder;
|
|
@@ -4994,7 +5044,7 @@ var CdpHosts = class {
|
|
|
4994
5044
|
if (!entry) throw new HttpError(503, NO_CDP_HOST);
|
|
4995
5045
|
let conn;
|
|
4996
5046
|
try {
|
|
4997
|
-
conn = await entry.hook(hookRequest(request3));
|
|
5047
|
+
conn = held(await entry.hook(hookRequest(request3)));
|
|
4998
5048
|
} catch (e) {
|
|
4999
5049
|
throw new HttpError(502, `CDP host: ${e instanceof Error ? e.message : String(e)}`);
|
|
5000
5050
|
}
|
|
@@ -5014,6 +5064,15 @@ var CdpHosts = class {
|
|
|
5014
5064
|
for (const entry of [this.embedder, ...this.clients]) if (entry) closeAll(entry);
|
|
5015
5065
|
}
|
|
5016
5066
|
};
|
|
5067
|
+
function held(host) {
|
|
5068
|
+
const { conn, message: message3, end } = heldConnection(
|
|
5069
|
+
(m) => host.send(m),
|
|
5070
|
+
() => host.close()
|
|
5071
|
+
);
|
|
5072
|
+
host.onmessage = message3;
|
|
5073
|
+
host.onclose = end;
|
|
5074
|
+
return conn;
|
|
5075
|
+
}
|
|
5017
5076
|
function hookRequest({ runtime, stamp }) {
|
|
5018
5077
|
return {
|
|
5019
5078
|
...runtime ? { runtime } : {},
|
|
@@ -5040,22 +5099,20 @@ function portCdpHook(ask, gone, ports = messageChannel) {
|
|
|
5040
5099
|
return (request3) => new Promise((resolve2, reject) => {
|
|
5041
5100
|
const { port1, port2 } = ports();
|
|
5042
5101
|
let closed = false;
|
|
5043
|
-
const
|
|
5044
|
-
|
|
5102
|
+
const held2 = heldConnection(
|
|
5103
|
+
(m) => {
|
|
5045
5104
|
if (!closed) port1.postMessage({ m });
|
|
5046
5105
|
},
|
|
5047
|
-
|
|
5048
|
-
onclose: null,
|
|
5049
|
-
close: () => {
|
|
5106
|
+
() => {
|
|
5050
5107
|
if (closed) return;
|
|
5051
5108
|
closed = true;
|
|
5052
5109
|
port1.postMessage({ close: true });
|
|
5053
5110
|
port1.close();
|
|
5054
5111
|
}
|
|
5055
|
-
|
|
5112
|
+
);
|
|
5056
5113
|
port1.addEventListener("message", ({ data }) => {
|
|
5057
|
-
if ("m" in data)
|
|
5058
|
-
else if ("open" in data) resolve2(conn);
|
|
5114
|
+
if ("m" in data) held2.message(data.m);
|
|
5115
|
+
else if ("open" in data) resolve2(held2.conn);
|
|
5059
5116
|
else if ("error" in data) {
|
|
5060
5117
|
closed = true;
|
|
5061
5118
|
port1.close();
|
|
@@ -5063,17 +5120,20 @@ function portCdpHook(ask, gone, ports = messageChannel) {
|
|
|
5063
5120
|
} else if (!closed) {
|
|
5064
5121
|
closed = true;
|
|
5065
5122
|
port1.close();
|
|
5066
|
-
|
|
5123
|
+
reject(new Error(data.close ?? "the CDP host closed"));
|
|
5124
|
+
held2.end(data.close ?? void 0);
|
|
5067
5125
|
}
|
|
5068
5126
|
});
|
|
5069
|
-
|
|
5070
|
-
void gone?.then(() => {
|
|
5127
|
+
const lost = (reason) => {
|
|
5071
5128
|
if (closed) return;
|
|
5072
5129
|
closed = true;
|
|
5073
5130
|
port1.close();
|
|
5074
|
-
reject(new Error(
|
|
5075
|
-
|
|
5076
|
-
}
|
|
5131
|
+
reject(new Error(reason));
|
|
5132
|
+
held2.end(reason);
|
|
5133
|
+
};
|
|
5134
|
+
port1.addEventListener("close", () => lost("the CDP host closed its port"));
|
|
5135
|
+
port1.start();
|
|
5136
|
+
void gone?.then(() => lost("the CDP host is gone"));
|
|
5077
5137
|
ask(request3, port2);
|
|
5078
5138
|
});
|
|
5079
5139
|
}
|
|
@@ -9071,7 +9131,7 @@ function satisfies(version, range2) {
|
|
|
9071
9131
|
}
|
|
9072
9132
|
|
|
9073
9133
|
// src/version.ts
|
|
9074
|
-
var KERNEL_VERSION = true ? "1.
|
|
9134
|
+
var KERNEL_VERSION = true ? "1.192.0" : "0.0.0-dev";
|
|
9075
9135
|
var OS_RELEASE = "6.0.0-slicc";
|
|
9076
9136
|
function procVersion() {
|
|
9077
9137
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -10414,15 +10474,15 @@ var UnlinkedKeeper = class {
|
|
|
10414
10474
|
pinned2.commit();
|
|
10415
10475
|
}
|
|
10416
10476
|
heldWithin(target) {
|
|
10417
|
-
const
|
|
10477
|
+
const held2 = /* @__PURE__ */ new Map();
|
|
10418
10478
|
for (const holder of this.holders) {
|
|
10419
10479
|
if (holder.owns(target)) continue;
|
|
10420
10480
|
for (const path of holder.held()) {
|
|
10421
10481
|
if (!within5(path, target) || holder.isKept(path)) continue;
|
|
10422
|
-
|
|
10482
|
+
held2.set(path, [...held2.get(path) ?? [], holder]);
|
|
10423
10483
|
}
|
|
10424
10484
|
}
|
|
10425
|
-
return
|
|
10485
|
+
return held2;
|
|
10426
10486
|
}
|
|
10427
10487
|
async pin(target, gated = () => void 0, sealed = () => void 0) {
|
|
10428
10488
|
const paths = [];
|
|
@@ -10445,18 +10505,18 @@ var UnlinkedKeeper = class {
|
|
|
10445
10505
|
};
|
|
10446
10506
|
await take();
|
|
10447
10507
|
gated();
|
|
10448
|
-
const
|
|
10508
|
+
const held2 = /* @__PURE__ */ new Map();
|
|
10449
10509
|
const hidden = /* @__PURE__ */ new Map();
|
|
10450
10510
|
const moved2 = [];
|
|
10451
10511
|
try {
|
|
10452
10512
|
for (; ; ) {
|
|
10453
10513
|
await take();
|
|
10454
10514
|
const now = this.heldWithin(target);
|
|
10455
|
-
const next3 = paths.filter((path) => now.has(path) && !
|
|
10515
|
+
const next3 = paths.filter((path) => now.has(path) && !held2.has(path));
|
|
10456
10516
|
if (next3.length === 0) break;
|
|
10457
10517
|
for (const path of next3) {
|
|
10458
10518
|
const holders = now.get(path);
|
|
10459
|
-
|
|
10519
|
+
held2.set(path, holders);
|
|
10460
10520
|
for (const holder of holders) moved2.push(holder.moving?.(path) ?? (() => void 0));
|
|
10461
10521
|
const at = await this.keepAside(path);
|
|
10462
10522
|
if (at === void 0) continue;
|
|
@@ -10480,7 +10540,7 @@ var UnlinkedKeeper = class {
|
|
|
10480
10540
|
};
|
|
10481
10541
|
const files = /* @__PURE__ */ new Map();
|
|
10482
10542
|
for (const [path, at] of hidden) {
|
|
10483
|
-
const holders =
|
|
10543
|
+
const holders = held2.get(path);
|
|
10484
10544
|
const file = this.keptFile(at, { refs: holders.length + 1 });
|
|
10485
10545
|
files.set(path, file);
|
|
10486
10546
|
for (const holder of holders) holder.keep(path, file);
|
|
@@ -10494,7 +10554,7 @@ var UnlinkedKeeper = class {
|
|
|
10494
10554
|
},
|
|
10495
10555
|
rollback: async () => {
|
|
10496
10556
|
for (const [path, file] of files) {
|
|
10497
|
-
for (const holder of
|
|
10557
|
+
for (const holder of held2.get(path)) holder.unkeep(path, file);
|
|
10498
10558
|
await this.serial(async () => {
|
|
10499
10559
|
await Promise.allSettled([this.fs.rename(file.hidden, path)]);
|
|
10500
10560
|
this.unlinkedName(file.hidden);
|
|
@@ -10527,10 +10587,10 @@ var UnlinkedKeeper = class {
|
|
|
10527
10587
|
const none = { whole: false, undoing: (op) => op() };
|
|
10528
10588
|
const peers = this.peers;
|
|
10529
10589
|
if (!peers?.shared() || this.rootOf(target) !== "/") return none;
|
|
10530
|
-
const
|
|
10531
|
-
if (
|
|
10590
|
+
const held2 = peers.heldWithin(target).filter((holder) => holder.instance !== void 0);
|
|
10591
|
+
if (held2.length === 0 || !await valid()) return none;
|
|
10532
10592
|
const tabs = /* @__PURE__ */ new Map();
|
|
10533
|
-
for (const holder of
|
|
10593
|
+
for (const holder of held2) tabs.set(holder.tab, [...tabs.get(holder.tab) ?? [], holder]);
|
|
10534
10594
|
const asked = [...tabs].map(([tab, holders]) => {
|
|
10535
10595
|
const paths = holders.map((holder) => holder.path);
|
|
10536
10596
|
return { tab, holders, paths };
|
|
@@ -10767,7 +10827,7 @@ var UnlinkedKeeper = class {
|
|
|
10767
10827
|
const dir = dirOf(root);
|
|
10768
10828
|
const names2 = await this.fs.readdir(dir).catch(() => void 0);
|
|
10769
10829
|
if (!names2) return;
|
|
10770
|
-
const
|
|
10830
|
+
const held2 = query && new Set(((await query()).held ?? []).map((lock) => lock.name));
|
|
10771
10831
|
for (const name2 of names2) {
|
|
10772
10832
|
const id2 = name2.slice(0, name2.lastIndexOf("."));
|
|
10773
10833
|
const at = id2.indexOf("~");
|
|
@@ -10780,7 +10840,7 @@ var UnlinkedKeeper = class {
|
|
|
10780
10840
|
);
|
|
10781
10841
|
continue;
|
|
10782
10842
|
}
|
|
10783
|
-
const dead = id2 !== this.instance && (at < 0 ?
|
|
10843
|
+
const dead = id2 !== this.instance && (at < 0 ? held2 !== void 0 && !held2.has(lockName(id2)) : owner?.alive(id2.slice(0, at)) === false);
|
|
10784
10844
|
if (dead) await this.fs.rm(`${dir}/${name2}`, { recursive: true }).catch(() => void 0);
|
|
10785
10845
|
}
|
|
10786
10846
|
await this.tidy(dir);
|
|
@@ -12708,11 +12768,11 @@ var TextBusy = class {
|
|
|
12708
12768
|
return exclusive.call(
|
|
12709
12769
|
fs,
|
|
12710
12770
|
path,
|
|
12711
|
-
(
|
|
12712
|
-
...
|
|
12771
|
+
(held2) => run2({
|
|
12772
|
+
...held2,
|
|
12713
12773
|
writeFile: async (at, content, owner) => {
|
|
12714
12774
|
await check(at);
|
|
12715
|
-
return
|
|
12775
|
+
return held2.writeFile(at, content, owner);
|
|
12716
12776
|
}
|
|
12717
12777
|
}),
|
|
12718
12778
|
follow2
|
|
@@ -13756,9 +13816,9 @@ var EmbedderChannel = class {
|
|
|
13756
13816
|
}
|
|
13757
13817
|
set caller(caller) {
|
|
13758
13818
|
this.current = caller;
|
|
13759
|
-
const
|
|
13819
|
+
const held2 = this.held;
|
|
13760
13820
|
this.held = [];
|
|
13761
|
-
for (const line of
|
|
13821
|
+
for (const line of held2) this.tell(line);
|
|
13762
13822
|
}
|
|
13763
13823
|
tell(line) {
|
|
13764
13824
|
if (!this.current.progress(line) && this.held.length < HELD_MAX) this.held.push(line);
|
|
@@ -15229,27 +15289,27 @@ var CwdTable = class {
|
|
|
15229
15289
|
return slot2;
|
|
15230
15290
|
}
|
|
15231
15291
|
share(slot2) {
|
|
15232
|
-
const
|
|
15233
|
-
if (!
|
|
15234
|
-
|
|
15292
|
+
const held2 = slot2 === void 0 ? void 0 : this.held.get(slot2);
|
|
15293
|
+
if (!held2) return UNTRACKED;
|
|
15294
|
+
held2.refs++;
|
|
15235
15295
|
return slot2;
|
|
15236
15296
|
}
|
|
15237
15297
|
release(slot2) {
|
|
15238
|
-
const
|
|
15239
|
-
if (!
|
|
15298
|
+
const held2 = slot2 === void 0 ? void 0 : this.held.get(slot2);
|
|
15299
|
+
if (!held2 || --held2.refs > 0) return;
|
|
15240
15300
|
this.held.delete(slot2);
|
|
15241
15301
|
Atomics.add(this.view, slot2, 1);
|
|
15242
15302
|
this.free.push(slot2);
|
|
15243
15303
|
}
|
|
15244
15304
|
stateOf(slot2) {
|
|
15245
|
-
const
|
|
15246
|
-
return { seen:
|
|
15305
|
+
const held2 = this.held.get(slot2);
|
|
15306
|
+
return { seen: held2?.verified ?? Atomics.load(this.view, slot2), dead: held2?.dead === true };
|
|
15247
15307
|
}
|
|
15248
15308
|
touched(paths, trees = []) {
|
|
15249
15309
|
if (this.held.size === 0) return;
|
|
15250
|
-
for (const [slot2,
|
|
15251
|
-
if (
|
|
15252
|
-
if (paths.some((p) => under4(
|
|
15310
|
+
for (const [slot2, held2] of this.held) {
|
|
15311
|
+
if (held2.dead) continue;
|
|
15312
|
+
if (paths.some((p) => under4(held2.path, p)) || trees.some((t) => under4(held2.path, t))) {
|
|
15253
15313
|
Atomics.add(this.view, slot2, 1);
|
|
15254
15314
|
}
|
|
15255
15315
|
}
|
|
@@ -15257,14 +15317,14 @@ var CwdTable = class {
|
|
|
15257
15317
|
async check(slot2) {
|
|
15258
15318
|
this.checks++;
|
|
15259
15319
|
const gen = Atomics.load(this.view, slot2);
|
|
15260
|
-
const
|
|
15261
|
-
if (!
|
|
15262
|
-
if (!
|
|
15263
|
-
const ino = await this.inodeOf(
|
|
15264
|
-
|
|
15265
|
-
|
|
15320
|
+
const held2 = this.held.get(slot2);
|
|
15321
|
+
if (!held2) return { gen, alive: true };
|
|
15322
|
+
if (!held2.dead) {
|
|
15323
|
+
const ino = await this.inodeOf(held2.path).catch(() => null);
|
|
15324
|
+
held2.dead = ino === null || held2.ino !== void 0 && ino !== held2.ino;
|
|
15325
|
+
held2.verified = gen;
|
|
15266
15326
|
}
|
|
15267
|
-
return { gen, alive: !
|
|
15327
|
+
return { gen, alive: !held2.dead };
|
|
15268
15328
|
}
|
|
15269
15329
|
};
|
|
15270
15330
|
function heldInit(o) {
|
|
@@ -15521,8 +15581,8 @@ var HeldSet = class extends Set {
|
|
|
15521
15581
|
return removed;
|
|
15522
15582
|
}
|
|
15523
15583
|
};
|
|
15524
|
-
function heldUnder(
|
|
15525
|
-
for (const paths of
|
|
15584
|
+
function heldUnder(held2, target) {
|
|
15585
|
+
for (const paths of held2) for (const path of paths.keys()) if (within8(path, target)) return true;
|
|
15526
15586
|
return false;
|
|
15527
15587
|
}
|
|
15528
15588
|
var HeldPaths = class extends Map {
|
|
@@ -17067,8 +17127,8 @@ function nothing2() {
|
|
|
17067
17127
|
return false;
|
|
17068
17128
|
}
|
|
17069
17129
|
function heldPaths(arg) {
|
|
17070
|
-
const
|
|
17071
|
-
return Array.isArray(
|
|
17130
|
+
const held2 = JSON.parse(arg ?? "[]");
|
|
17131
|
+
return Array.isArray(held2) ? held2.filter((path) => typeof path === "string") : [];
|
|
17072
17132
|
}
|
|
17073
17133
|
async function usageAt(entry, path) {
|
|
17074
17134
|
if (!entry.statfs) return void 0;
|
|
@@ -17631,11 +17691,11 @@ async function dispatchSyncFs(req) {
|
|
|
17631
17691
|
return devsOf(entry, req, await dispatchOne(entry, req));
|
|
17632
17692
|
const { fs, cwd } = entry;
|
|
17633
17693
|
const path = fs.resolvePath(cwd, req.path);
|
|
17634
|
-
const identified = async (
|
|
17635
|
-
const own =
|
|
17694
|
+
const identified = async (held2) => {
|
|
17695
|
+
const own = held2 ? { ...entry, fs: { ...fs, writeFile: held2.writeFile } } : entry;
|
|
17636
17696
|
const result = await dispatchOne(own, req);
|
|
17637
17697
|
if (!result.ok) return result;
|
|
17638
|
-
if (
|
|
17698
|
+
if (held2 && !held2.direct) return json2(null);
|
|
17639
17699
|
const look = req.op === "lchown" ? fs.lstat : fs.stat;
|
|
17640
17700
|
const st = await look.call(fs, path).catch(() => void 0);
|
|
17641
17701
|
return json2(st ? statJson(st) : null);
|
|
@@ -17782,8 +17842,8 @@ async function dispatchPath(entry, req) {
|
|
|
17782
17842
|
if (device) return { ok: false, errno: device, message: `${path}: a device entry stays` };
|
|
17783
17843
|
const made2 = await newDevName(entry, path, req);
|
|
17784
17844
|
if (made2) return made2;
|
|
17785
|
-
const
|
|
17786
|
-
if (
|
|
17845
|
+
const held2 = await byHandle(entry, path, req);
|
|
17846
|
+
if (held2) return held2;
|
|
17787
17847
|
if (req.op === "access") return await accessOp(entry, path, req);
|
|
17788
17848
|
if (req.op === "hold") return await holdOp(entry, path, req);
|
|
17789
17849
|
const resolved2 = await guardAndResolve(entry, path, req);
|
|
@@ -23287,10 +23347,10 @@ async function recordLock2(req, ctx) {
|
|
|
23287
23347
|
const range2 = lockRange(req.start, req.len);
|
|
23288
23348
|
const key = await fileKey(target, req.kind, req.op === "lk-set" && req.fd !== void 0);
|
|
23289
23349
|
if (req.op === "lk-get") {
|
|
23290
|
-
const
|
|
23291
|
-
if (!
|
|
23292
|
-
const len =
|
|
23293
|
-
return json3({ kind:
|
|
23350
|
+
const held2 = await locks.holder(key, owner, { key, kind: req.kind, ...range2 });
|
|
23351
|
+
if (!held2) return json3(null);
|
|
23352
|
+
const len = held2.end === Number.POSITIVE_INFINITY ? 0 : held2.end - held2.start;
|
|
23353
|
+
return json3({ kind: held2.kind, pid: held2.owner, start: held2.start, len });
|
|
23294
23354
|
}
|
|
23295
23355
|
const granted2 = req.kind !== "unlock";
|
|
23296
23356
|
const shared2 = locks.shared?.() === true;
|
|
@@ -27785,8 +27845,8 @@ var TlsContext = class {
|
|
|
27785
27845
|
var TLS_CONTEXTS_MAX = 64;
|
|
27786
27846
|
async function contextSecure(proc, cert) {
|
|
27787
27847
|
if (!cert) throw new KernelError("EINVAL", "ERR_INVALID_ARG_VALUE: a context needs cert and key");
|
|
27788
|
-
const
|
|
27789
|
-
if (
|
|
27848
|
+
const held2 = proc.fds.numbers().filter((fd) => proc.fds.get(fd).file instanceof TlsContext);
|
|
27849
|
+
if (held2.length >= TLS_CONTEXTS_MAX) {
|
|
27790
27850
|
wipe(certBytes(cert));
|
|
27791
27851
|
throw new KernelError("EMFILE", `at most ${TLS_CONTEXTS_MAX} tls contexts per process`);
|
|
27792
27852
|
}
|
|
@@ -27805,14 +27865,14 @@ function contextAt(fds, fd) {
|
|
|
27805
27865
|
const open2 = fds.get(fd);
|
|
27806
27866
|
const file = open2.file;
|
|
27807
27867
|
if (!(file instanceof TlsContext)) throw new KernelError("EBADF", "not a tls context");
|
|
27808
|
-
const
|
|
27868
|
+
const held2 = open2.retain();
|
|
27809
27869
|
let released2 = false;
|
|
27810
27870
|
return {
|
|
27811
27871
|
leaf: file.leaf,
|
|
27812
27872
|
done: () => {
|
|
27813
27873
|
if (released2) return;
|
|
27814
27874
|
released2 = true;
|
|
27815
|
-
void
|
|
27875
|
+
void held2.release();
|
|
27816
27876
|
}
|
|
27817
27877
|
};
|
|
27818
27878
|
}
|
|
@@ -29050,8 +29110,8 @@ var VfsNodes = class {
|
|
|
29050
29110
|
createExclusive(path, owner) {
|
|
29051
29111
|
return this.onEntry(path, async () => {
|
|
29052
29112
|
const node = this.byPath.get(path);
|
|
29053
|
-
const
|
|
29054
|
-
if (
|
|
29113
|
+
const held2 = node ? await node.serial(async () => node.holds()) : false;
|
|
29114
|
+
if (held2) throw fsError("EEXIST", path);
|
|
29055
29115
|
const exclusive = this.fs.createExclusive;
|
|
29056
29116
|
if (exclusive) return exclusive.call(this.fs, path, owner);
|
|
29057
29117
|
if (await present3(this.fs, path)) throw fsError("EEXIST", path);
|
|
@@ -29283,8 +29343,8 @@ var VfsNodes = class {
|
|
|
29283
29343
|
for (const [p, node] of this.byPath) if (within10(p, path)) await node.serial(() => node.flush());
|
|
29284
29344
|
}
|
|
29285
29345
|
async unlinking(path) {
|
|
29286
|
-
for (const [
|
|
29287
|
-
if (!within10(
|
|
29346
|
+
for (const [held2, node] of [...this.byPath]) {
|
|
29347
|
+
if (!within10(held2, path)) continue;
|
|
29288
29348
|
await node.serial(async () => {
|
|
29289
29349
|
await Promise.all([this.keepsOnDisk || node.keep(), node.limit()]);
|
|
29290
29350
|
});
|
|
@@ -29298,9 +29358,9 @@ var VfsNodes = class {
|
|
|
29298
29358
|
}
|
|
29299
29359
|
}
|
|
29300
29360
|
unlinked(path) {
|
|
29301
|
-
for (const [
|
|
29302
|
-
if (!within10(
|
|
29303
|
-
if (!this.dropName(
|
|
29361
|
+
for (const [held2, node] of [...this.byPath]) {
|
|
29362
|
+
if (!within10(held2, path) || this.byPath.get(held2) !== node) continue;
|
|
29363
|
+
if (!this.dropName(held2, node)) this.orphan(node);
|
|
29304
29364
|
}
|
|
29305
29365
|
}
|
|
29306
29366
|
renamed(from, to) {
|
|
@@ -29366,8 +29426,8 @@ async function aliasOf(fs, nodes, at) {
|
|
|
29366
29426
|
return nodes.holdingId(`${st.dev ?? 0}:${st.ino}`);
|
|
29367
29427
|
}
|
|
29368
29428
|
async function heldAt(fs, nodes, at) {
|
|
29369
|
-
const
|
|
29370
|
-
if (
|
|
29429
|
+
const held2 = nodes.holding(at);
|
|
29430
|
+
if (held2 || !nodes.holdsAny() || nodes.plainAt(at)) return held2;
|
|
29371
29431
|
const shape = nodes.shape;
|
|
29372
29432
|
const found = await aliasOf(fs, nodes, at);
|
|
29373
29433
|
if (!found) nodes.notePlain(at, shape);
|
|
@@ -29377,21 +29437,21 @@ function heldIo(fs, nodes, changed) {
|
|
|
29377
29437
|
const ranged2 = rangedOps(fs);
|
|
29378
29438
|
const node = (path) => heldAt(fs, nodes, fs.resolvePath("/", path));
|
|
29379
29439
|
const write = async (path, op, fallback) => {
|
|
29380
|
-
const
|
|
29381
|
-
if (!
|
|
29382
|
-
const out = await
|
|
29383
|
-
const done5 = await op(
|
|
29384
|
-
await
|
|
29440
|
+
const held2 = await node(path);
|
|
29441
|
+
if (!held2) return fallback();
|
|
29442
|
+
const out = await held2.byName(async () => {
|
|
29443
|
+
const done5 = await op(held2);
|
|
29444
|
+
await held2.flush();
|
|
29385
29445
|
return done5;
|
|
29386
29446
|
});
|
|
29387
29447
|
changed(fs.resolvePath("/", path));
|
|
29388
|
-
if (
|
|
29448
|
+
if (held2.path !== fs.resolvePath("/", path)) changed(held2.path);
|
|
29389
29449
|
return out;
|
|
29390
29450
|
};
|
|
29391
29451
|
return {
|
|
29392
29452
|
append: (path, bytes) => write(
|
|
29393
29453
|
path,
|
|
29394
|
-
(
|
|
29454
|
+
(held2) => held2.append(bytes),
|
|
29395
29455
|
async () => {
|
|
29396
29456
|
const end = await fs.append?.(path, bytes, { alone: true }).catch((err) => {
|
|
29397
29457
|
if (!positional(err)) throw err;
|
|
@@ -29411,32 +29471,32 @@ function heldIo(fs, nodes, changed) {
|
|
|
29411
29471
|
),
|
|
29412
29472
|
async stat(path) {
|
|
29413
29473
|
const st = await fs.stat(path);
|
|
29414
|
-
const
|
|
29415
|
-
return
|
|
29474
|
+
const held2 = st.isFile ? await node(path) : void 0;
|
|
29475
|
+
return held2 ? { ...st, size: await held2.byName(() => held2.size()) } : st;
|
|
29416
29476
|
},
|
|
29417
29477
|
async lstat(path) {
|
|
29418
29478
|
const st = await fs.lstat(path);
|
|
29419
|
-
const
|
|
29420
|
-
return
|
|
29479
|
+
const held2 = st.isFile && !st.isSymbolicLink ? await node(path) : void 0;
|
|
29480
|
+
return held2 ? { ...st, size: await held2.byName(() => held2.size()) } : st;
|
|
29421
29481
|
},
|
|
29422
29482
|
async readFileBuffer(path) {
|
|
29423
|
-
const
|
|
29424
|
-
if (!
|
|
29425
|
-
return
|
|
29483
|
+
const held2 = await node(path);
|
|
29484
|
+
if (!held2) return fs.readFileBuffer(path);
|
|
29485
|
+
return held2.byName(async () => held2.pread(await held2.size(), 0));
|
|
29426
29486
|
},
|
|
29427
29487
|
...ranged2 ? {
|
|
29428
29488
|
pread: async (path, at, n, version) => {
|
|
29429
|
-
const
|
|
29430
|
-
return
|
|
29489
|
+
const held2 = await node(path);
|
|
29490
|
+
return held2 ? held2.byName(() => held2.pread(n, at)) : ranged2.pread(path, at, n, version);
|
|
29431
29491
|
},
|
|
29432
29492
|
pwrite: (path, at, bytes, transfer, options) => write(
|
|
29433
29493
|
path,
|
|
29434
|
-
async (
|
|
29494
|
+
async (held2) => void await held2.pwrite(bytes, at),
|
|
29435
29495
|
() => ranged2.pwrite(path, at, bytes, transfer, options)
|
|
29436
29496
|
),
|
|
29437
29497
|
truncate: (path, size) => write(
|
|
29438
29498
|
path,
|
|
29439
|
-
(
|
|
29499
|
+
(held2) => held2.truncate(size),
|
|
29440
29500
|
() => ranged2.truncate(path, size)
|
|
29441
29501
|
)
|
|
29442
29502
|
} : {}
|
|
@@ -29477,15 +29537,15 @@ function keepingOpen(fs, nodes, changed = () => {
|
|
|
29477
29537
|
},
|
|
29478
29538
|
writeFile: async (path, content, owner) => {
|
|
29479
29539
|
const at = fs.resolvePath("/", path);
|
|
29480
|
-
const
|
|
29481
|
-
if (!
|
|
29540
|
+
const held2 = await heldAt(fs, nodes, at);
|
|
29541
|
+
if (!held2) return nodes.onEntry(at, () => fs.writeFile(path, content, owner));
|
|
29482
29542
|
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
29483
|
-
return
|
|
29484
|
-
await
|
|
29485
|
-
await
|
|
29486
|
-
await
|
|
29543
|
+
return held2.byName(async () => {
|
|
29544
|
+
await held2.truncate(0);
|
|
29545
|
+
await held2.pwrite(bytes, 0);
|
|
29546
|
+
await held2.flush();
|
|
29487
29547
|
changed(at);
|
|
29488
|
-
if (
|
|
29548
|
+
if (held2.path !== at) changed(held2.path);
|
|
29489
29549
|
});
|
|
29490
29550
|
},
|
|
29491
29551
|
createExclusive: async (path, owner) => nodes.createExclusive(await nodes.entryKey(fs.resolvePath("/", path)), owner),
|
|
@@ -31788,12 +31848,12 @@ var Dying = class {
|
|
|
31788
31848
|
};
|
|
31789
31849
|
function killThread(thread, caught, sig) {
|
|
31790
31850
|
if (!thread) return false;
|
|
31791
|
-
const
|
|
31792
|
-
if (!
|
|
31851
|
+
const held2 = (Atomics.load(thread.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
31852
|
+
if (!held2 && (caught & sigbit(sig)) === 0) return false;
|
|
31793
31853
|
Atomics.or(thread.header, SAB_I_SIGNALS, sigbit(sig));
|
|
31794
31854
|
Atomics.notify(thread.header, SAB_I_SIGNALS);
|
|
31795
31855
|
headerNotified(thread.header, SAB_I_SIGNALS, sigbit(sig));
|
|
31796
|
-
if (
|
|
31856
|
+
if (held2) return true;
|
|
31797
31857
|
const blocked2 = thread.interrupt;
|
|
31798
31858
|
thread.interrupt = new AbortController();
|
|
31799
31859
|
blocked2.abort();
|
|
@@ -32608,9 +32668,9 @@ var LockService = class {
|
|
|
32608
32668
|
case "set":
|
|
32609
32669
|
return t.set(ask.key, this.ownerFor(from, ask.owner), ask.kind, ask.start, ask.end);
|
|
32610
32670
|
case "holder": {
|
|
32611
|
-
const
|
|
32612
|
-
if (!
|
|
32613
|
-
return { ...
|
|
32671
|
+
const held2 = t.holder(ask.key, this.ownerFor(from, ask.owner), ask);
|
|
32672
|
+
if (!held2) return void 0;
|
|
32673
|
+
return { ...held2, owner: this.ownerOf.get(held2.owner)?.owner ?? held2.owner };
|
|
32614
32674
|
}
|
|
32615
32675
|
case "wait":
|
|
32616
32676
|
return this.blockFor(
|
|
@@ -32654,15 +32714,15 @@ var LockService = class {
|
|
|
32654
32714
|
this.pruner.unref?.();
|
|
32655
32715
|
}
|
|
32656
32716
|
async prune() {
|
|
32657
|
-
const
|
|
32717
|
+
const held2 = new Set(((await this.locks.query()).held ?? []).map((l) => l.name));
|
|
32658
32718
|
for (const [id2, { kernel, owner }] of [...this.ownerOf]) {
|
|
32659
|
-
if (
|
|
32719
|
+
if (held2.has(this.aliveOf(kernel))) continue;
|
|
32660
32720
|
this.table.release(id2);
|
|
32661
32721
|
this.ownerOf.delete(id2);
|
|
32662
32722
|
this.owners.delete(`${kernel}:${owner}`);
|
|
32663
32723
|
}
|
|
32664
32724
|
for (const [name2, token] of [...this.tokens]) {
|
|
32665
|
-
if (
|
|
32725
|
+
if (held2.has(this.aliveOf(name2.slice(0, name2.lastIndexOf(":"))))) continue;
|
|
32666
32726
|
this.table.flocks.drop(token);
|
|
32667
32727
|
this.tokens.delete(name2);
|
|
32668
32728
|
}
|
|
@@ -32678,11 +32738,11 @@ var LockService = class {
|
|
|
32678
32738
|
for (const [id2, p] of this.pending)
|
|
32679
32739
|
this.channel.postMessage({ id: id2, from: this.kernel, ask: p.ask });
|
|
32680
32740
|
}
|
|
32681
|
-
adopt(from,
|
|
32682
|
-
for (const [key, locks] of
|
|
32741
|
+
adopt(from, held2) {
|
|
32742
|
+
for (const [key, locks] of held2.records)
|
|
32683
32743
|
for (const l of locks)
|
|
32684
32744
|
this.table.set(key, this.ownerFor(from, l.owner), l.kind, l.start, l.end);
|
|
32685
|
-
for (const [key, owner, kind] of
|
|
32745
|
+
for (const [key, owner, kind] of held2.flocks)
|
|
32686
32746
|
this.table.flocks.set(key, this.tokenFor(from, owner), kind);
|
|
32687
32747
|
}
|
|
32688
32748
|
flockIdOf(owner) {
|
|
@@ -33081,23 +33141,23 @@ function bodiless(hop) {
|
|
|
33081
33141
|
}
|
|
33082
33142
|
function replayingHops(inner, heldMs = HELD_MS) {
|
|
33083
33143
|
if (!inner.traits.redirectHops || inner.traits.manualRedirects) return inner;
|
|
33084
|
-
const
|
|
33144
|
+
const held2 = /* @__PURE__ */ new Map();
|
|
33085
33145
|
const drop = (key) => {
|
|
33086
|
-
const entry =
|
|
33146
|
+
const entry = held2.get(key);
|
|
33087
33147
|
if (!entry) return;
|
|
33088
|
-
|
|
33148
|
+
held2.delete(key);
|
|
33089
33149
|
clearTimeout(entry.timer);
|
|
33090
33150
|
void entry.final.cancel().catch(() => void 0);
|
|
33091
33151
|
};
|
|
33092
33152
|
const keyOf3 = (owner, method, url) => `${owner} ${method} ${url}`;
|
|
33093
33153
|
const hold = (key, chain2) => {
|
|
33094
33154
|
drop(key);
|
|
33095
|
-
const mine = [...
|
|
33155
|
+
const mine = [...held2.keys()].filter((k) => held2.get(k)?.owner === chain2.owner);
|
|
33096
33156
|
if (mine.length >= HELD_PER_OWNER) drop(mine[0]);
|
|
33097
|
-
if (
|
|
33157
|
+
if (held2.size >= HELD_MAX2) drop(held2.keys().next().value);
|
|
33098
33158
|
const timer = setTimeout(() => drop(key), heldMs);
|
|
33099
33159
|
timer.unref?.();
|
|
33100
|
-
|
|
33160
|
+
held2.set(key, { ...chain2, timer });
|
|
33101
33161
|
};
|
|
33102
33162
|
const replay = (chain2) => {
|
|
33103
33163
|
const [hop, ...rest2] = chain2.hops;
|
|
@@ -33126,9 +33186,9 @@ function replayingHops(inner, heldMs = HELD_MS) {
|
|
|
33126
33186
|
const [caller] = rest2;
|
|
33127
33187
|
const owner = caller ?? KERNEL;
|
|
33128
33188
|
const key = keyOf3(owner, request3.method, request3.url);
|
|
33129
|
-
const waiting =
|
|
33189
|
+
const waiting = held2.get(key);
|
|
33130
33190
|
if (waiting && waiting.fingerprint === fingerprint(request3.headers)) {
|
|
33131
|
-
|
|
33191
|
+
held2.delete(key);
|
|
33132
33192
|
clearTimeout(waiting.timer);
|
|
33133
33193
|
return replay(waiting);
|
|
33134
33194
|
}
|
|
@@ -33406,10 +33466,10 @@ var RenameLog = class {
|
|
|
33406
33466
|
}
|
|
33407
33467
|
return void 0;
|
|
33408
33468
|
}
|
|
33409
|
-
since(seen,
|
|
33469
|
+
since(seen, held2) {
|
|
33410
33470
|
const now = this.entries.at(-1)?.seq ?? seen;
|
|
33411
33471
|
const renames = [];
|
|
33412
|
-
let paths = [...
|
|
33472
|
+
let paths = [...held2];
|
|
33413
33473
|
for (const { seq: seq2, from, to } of this.entries) {
|
|
33414
33474
|
if (seq2 <= seen || !paths.some((path) => within11(path, from))) continue;
|
|
33415
33475
|
renames.push([from, to]);
|
|
@@ -33454,11 +33514,11 @@ var PackageLocks = class {
|
|
|
33454
33514
|
const { locks } = this;
|
|
33455
33515
|
if (!locks) return Promise.resolve(() => {
|
|
33456
33516
|
});
|
|
33457
|
-
const { promise:
|
|
33517
|
+
const { promise: held2, resolve: release } = Promise.withResolvers();
|
|
33458
33518
|
return new Promise((granted2, failed4) => {
|
|
33459
33519
|
locks.request(replacingLock(this.metadata, root), { mode: "exclusive" }, () => {
|
|
33460
33520
|
granted2(() => release());
|
|
33461
|
-
return
|
|
33521
|
+
return held2;
|
|
33462
33522
|
}).catch(failed4);
|
|
33463
33523
|
});
|
|
33464
33524
|
}
|
|
@@ -36968,34 +37028,34 @@ var Launcher = class {
|
|
|
36968
37028
|
known.users++;
|
|
36969
37029
|
return known.made;
|
|
36970
37030
|
}
|
|
36971
|
-
const
|
|
37031
|
+
const held2 = {
|
|
36972
37032
|
made: (this.moduleUrl ?? dataModuleUrl)(source),
|
|
36973
37033
|
users: 1,
|
|
36974
37034
|
evicted: false
|
|
36975
37035
|
};
|
|
36976
|
-
this.moduleUrls.set(source,
|
|
36977
|
-
this.urlsInUse.set(
|
|
37036
|
+
this.moduleUrls.set(source, held2);
|
|
37037
|
+
this.urlsInUse.set(held2.made.url, held2);
|
|
36978
37038
|
for (const [old, entry] of this.moduleUrls) {
|
|
36979
37039
|
if (this.moduleUrls.size <= MODULE_URLS) break;
|
|
36980
37040
|
this.moduleUrls.delete(old);
|
|
36981
37041
|
entry.evicted = true;
|
|
36982
37042
|
this.releaseUrl(entry);
|
|
36983
37043
|
}
|
|
36984
|
-
return
|
|
37044
|
+
return held2.made;
|
|
36985
37045
|
}
|
|
36986
37046
|
heldUrl(program) {
|
|
36987
|
-
const
|
|
36988
|
-
if (!
|
|
37047
|
+
const held2 = program.abi === "js" && program.url ? this.urlsInUse.get(program.url) : void 0;
|
|
37048
|
+
if (!held2) return () => {
|
|
36989
37049
|
};
|
|
36990
37050
|
return () => {
|
|
36991
|
-
|
|
36992
|
-
this.releaseUrl(
|
|
37051
|
+
held2.users--;
|
|
37052
|
+
this.releaseUrl(held2);
|
|
36993
37053
|
};
|
|
36994
37054
|
}
|
|
36995
|
-
releaseUrl(
|
|
36996
|
-
if (!
|
|
36997
|
-
if (this.urlsInUse.get(
|
|
36998
|
-
|
|
37055
|
+
releaseUrl(held2) {
|
|
37056
|
+
if (!held2.evicted || held2.users > 0) return;
|
|
37057
|
+
if (this.urlsInUse.get(held2.made.url) === held2) this.urlsInUse.delete(held2.made.url);
|
|
37058
|
+
held2.made.revoke();
|
|
36999
37059
|
}
|
|
37000
37060
|
async names(path) {
|
|
37001
37061
|
const beside = `${path}.names`;
|
|
@@ -37082,10 +37142,10 @@ var Launcher = class {
|
|
|
37082
37142
|
}
|
|
37083
37143
|
const mine = hold;
|
|
37084
37144
|
mine.users++;
|
|
37085
|
-
let
|
|
37145
|
+
let held2 = true;
|
|
37086
37146
|
return () => {
|
|
37087
|
-
if (!
|
|
37088
|
-
|
|
37147
|
+
if (!held2) return;
|
|
37148
|
+
held2 = false;
|
|
37089
37149
|
if (--mine.users > 0) return;
|
|
37090
37150
|
holds3.delete(mine);
|
|
37091
37151
|
if (holds3.size === 0 && this.imageHolds.get(path) === holds3) this.imageHolds.delete(path);
|
|
@@ -37248,16 +37308,16 @@ var Launcher = class {
|
|
|
37248
37308
|
let roots = this.packageRoots(planned);
|
|
37249
37309
|
let stale = false;
|
|
37250
37310
|
for (; ; ) {
|
|
37251
|
-
const
|
|
37252
|
-
const done5 = await this.packageLocks.loading(
|
|
37311
|
+
const held2 = roots;
|
|
37312
|
+
const done5 = await this.packageLocks.loading(held2, async (waited) => {
|
|
37253
37313
|
if (!waited && !stale) return { value: await load(planned) };
|
|
37254
|
-
this.rootFs.refresh?.(
|
|
37314
|
+
this.rootFs.refresh?.(held2);
|
|
37255
37315
|
this.resetCatalogs();
|
|
37256
37316
|
if (replan) planned = await replan() ?? planned;
|
|
37257
37317
|
await recheck?.(planned);
|
|
37258
37318
|
const now = this.packageRoots(planned);
|
|
37259
|
-
if (now.every((root) =>
|
|
37260
|
-
roots = [.../* @__PURE__ */ new Set([...
|
|
37319
|
+
if (now.every((root) => held2.includes(root))) return { value: await load(planned) };
|
|
37320
|
+
roots = [.../* @__PURE__ */ new Set([...held2, ...now])].sort();
|
|
37261
37321
|
stale = true;
|
|
37262
37322
|
return void 0;
|
|
37263
37323
|
});
|
|
@@ -37465,7 +37525,7 @@ var Launcher = class {
|
|
|
37465
37525
|
unlinkGate: stack.unlinked.gate,
|
|
37466
37526
|
replacements: stack.unlinked,
|
|
37467
37527
|
statfs: (path) => this.mounts.statfs(path),
|
|
37468
|
-
renames: (since,
|
|
37528
|
+
renames: (since, held2) => this.renameLog.since(since, held2),
|
|
37469
37529
|
fileId: (path) => this.locks.shared?.() === true ? this.rootFileId(path) : void 0,
|
|
37470
37530
|
announceHold: (path, fid, created4) => this.locks.shared?.() === true && this.mounts.locate(path) === void 0 ? this.rootFs.announceHolds?.([[path, fid]], [], !created4) : void 0,
|
|
37471
37531
|
renameSeq: (from, to) => this.renameLog.seqOf(from, to),
|
|
@@ -37658,17 +37718,17 @@ var Launcher = class {
|
|
|
37658
37718
|
const tags = this.tagsOf(pid);
|
|
37659
37719
|
const cred = this.credOf(pid);
|
|
37660
37720
|
if (!this.traces.wants(tags, cred)) return;
|
|
37661
|
-
const
|
|
37662
|
-
if (
|
|
37721
|
+
const held2 = this.traceHeld.get(pid);
|
|
37722
|
+
if (held2) held2.events.push({ tags, cred: copyCred(cred), draft: build() });
|
|
37663
37723
|
else this.traces.publish(tags, cred, build());
|
|
37664
37724
|
}
|
|
37665
37725
|
traceAdmitted(pid, fit) {
|
|
37666
|
-
const
|
|
37667
|
-
if (!
|
|
37726
|
+
const held2 = this.traceHeld.get(pid);
|
|
37727
|
+
if (!held2) return;
|
|
37668
37728
|
this.traceHeld.delete(pid);
|
|
37669
37729
|
if (!fit) return;
|
|
37670
|
-
if (
|
|
37671
|
-
for (const { tags, cred, draft } of
|
|
37730
|
+
if (held2.replaces !== void 0) this.replacedImages.add(held2.replaces);
|
|
37731
|
+
for (const { tags, cred, draft } of held2.events) this.traces.publish(tags, cred, draft);
|
|
37672
37732
|
}
|
|
37673
37733
|
chainTimes(pid) {
|
|
37674
37734
|
let utime = 0;
|
|
@@ -38633,10 +38693,10 @@ var Launcher = class {
|
|
|
38633
38693
|
}
|
|
38634
38694
|
announceHeld() {
|
|
38635
38695
|
const nodes = [...this.openFiles].flatMap((open2) => open2.heldIds());
|
|
38636
|
-
const
|
|
38696
|
+
const held2 = [...this.held.heldIds(), ...nodes].filter(
|
|
38637
38697
|
([path]) => this.mounts.locate(path) === void 0 && !path.startsWith(`/${UNLINKED_DIR}/`)
|
|
38638
38698
|
);
|
|
38639
|
-
return
|
|
38699
|
+
return held2.length === 0 ? void 0 : this.rootFs.announceHolds?.(held2, [], false);
|
|
38640
38700
|
}
|
|
38641
38701
|
rootFileId(path) {
|
|
38642
38702
|
return this.mounts.locate(path) === void 0 ? this.rootFs.bindId?.(path) : void 0;
|
|
@@ -39399,7 +39459,7 @@ async function connectClient(deps, { user, tag, requests: bind2, devices }) {
|
|
|
39399
39459
|
throw fsError("ENOENT", `no user ${String(user)}`);
|
|
39400
39460
|
}
|
|
39401
39461
|
const { port1, port2 } = new MessageChannel();
|
|
39402
|
-
const
|
|
39462
|
+
const held2 = deps.held ? await deps.held() : void 0;
|
|
39403
39463
|
const client = ++clientIds;
|
|
39404
39464
|
const served2 = serveClient(port1, {
|
|
39405
39465
|
launcher: deps.ready,
|
|
@@ -39410,7 +39470,7 @@ async function connectClient(deps, { user, tag, requests: bind2, devices }) {
|
|
|
39410
39470
|
...user !== void 0 ? { user } : {},
|
|
39411
39471
|
...tag !== void 0 ? { tag } : {},
|
|
39412
39472
|
...deps.locks ? { locks: deps.locks } : {},
|
|
39413
|
-
...
|
|
39473
|
+
...held2 ? { lock: held2 } : {}
|
|
39414
39474
|
});
|
|
39415
39475
|
deps.clients.add(served2);
|
|
39416
39476
|
const unbind = bind2 && bind2 !== "attach" ? l.embedder.register(client, deps.requests.hookFor(client, bind2)) : void 0;
|