@ai-ecoverse/slicc-kernel 1.94.2 → 1.94.4

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/dist/node.js CHANGED
@@ -2427,6 +2427,8 @@ var UserDb = class {
2427
2427
  owners;
2428
2428
  umasks = /* @__PURE__ */ new Map();
2429
2429
  writing = Promise.resolve();
2430
+ stable;
2431
+ commits = 0;
2430
2432
  constructor(fs, owners = false) {
2431
2433
  this.fs = fs;
2432
2434
  this.owners = owners;
@@ -2462,11 +2464,18 @@ var UserDb = class {
2462
2464
  throw err;
2463
2465
  }
2464
2466
  }
2467
+ async texts() {
2468
+ for (; ; ) {
2469
+ if (this.stable) return this.stable;
2470
+ const commits = this.commits;
2471
+ const passwd = await this.read(PASSWD, DEFAULT_PASSWD);
2472
+ const group = await this.read(GROUP, DEFAULT_GROUP);
2473
+ if (this.commits === commits && !this.stable) return [passwd, group];
2474
+ }
2475
+ }
2465
2476
  async tables() {
2466
- return {
2467
- passwd: parsePasswd(await this.read(PASSWD, DEFAULT_PASSWD)),
2468
- group: parseGroup(await this.read(GROUP, DEFAULT_GROUP))
2469
- };
2477
+ const [passwd, group] = await this.texts();
2478
+ return { passwd: parsePasswd(passwd), group: parseGroup(group) };
2470
2479
  }
2471
2480
  async provision(row, umask, shared) {
2472
2481
  const dirs = 511 & ~umask | (shared ? 1024 : 0);
@@ -2485,15 +2494,25 @@ var UserDb = class {
2485
2494
  }
2486
2495
  }
2487
2496
  async commit(passwd, group, then) {
2488
- const before = [await this.read(PASSWD, DEFAULT_PASSWD), await this.read(GROUP, DEFAULT_GROUP)];
2497
+ const before = [
2498
+ await this.read(PASSWD, DEFAULT_PASSWD),
2499
+ await this.read(GROUP, DEFAULT_GROUP)
2500
+ ];
2501
+ this.stable = before;
2502
+ this.commits++;
2489
2503
  try {
2490
2504
  await this.fs.writeFile(GROUP, group);
2491
2505
  await this.fs.writeFile(PASSWD, passwd);
2506
+ this.stable = void 0;
2492
2507
  await then?.();
2493
2508
  } catch (err) {
2509
+ this.stable = before;
2494
2510
  await this.fs.writeFile(GROUP, before[1]);
2495
2511
  await this.fs.writeFile(PASSWD, before[0]);
2496
2512
  throw err;
2513
+ } finally {
2514
+ this.stable = void 0;
2515
+ this.commits++;
2497
2516
  }
2498
2517
  }
2499
2518
  serial(work) {
@@ -10624,7 +10643,7 @@ function mountTable(mounts = []) {
10624
10643
  }
10625
10644
 
10626
10645
  // src/version.ts
10627
- var KERNEL_VERSION = true ? "1.94.2" : "0.0.0-dev";
10646
+ var KERNEL_VERSION = true ? "1.94.4" : "0.0.0-dev";
10628
10647
  var OS_RELEASE = "6.0.0-slicc";
10629
10648
  function procVersion() {
10630
10649
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -11397,7 +11416,7 @@ var KernelLoopback = class {
11397
11416
  if (head.status !== 101) {
11398
11417
  throw errno(
11399
11418
  "EPROTO",
11400
- `the server answered ${head.status} ${head.statusText}, not an upgrade`
11419
+ `the server answered the upgrade with ${head.status}${head.statusText ? ` ${head.statusText}` : ""}`
11401
11420
  );
11402
11421
  }
11403
11422
  const upgraded = fieldTokens(head.headers, "upgrade").includes("websocket") && fieldTokens(head.headers, "connection").includes("upgrade");
@@ -22512,7 +22531,7 @@ async function createNodeKernel(options = {}) {
22512
22531
  async connect({ user, tag } = {}) {
22513
22532
  if (terminated) throw new Error(TERMINATED);
22514
22533
  tagOption(tag);
22515
- if (user !== void 0 && !await launcher.users.lookup(user)) {
22534
+ if (user !== void 0 && !await guard2(() => launcher.users.lookup(user))) {
22516
22535
  throw fsError("ENOENT", `no user ${String(user)}`);
22517
22536
  }
22518
22537
  const { port1, port2 } = new MessageChannel2();