@ai-ecoverse/slicc-kernel 1.100.1 → 1.100.3

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.
@@ -4767,7 +4767,7 @@ var KERNEL_VERSION, OS_RELEASE;
4767
4767
  var init_version = __esm({
4768
4768
  "src/version.ts"() {
4769
4769
  "use strict";
4770
- KERNEL_VERSION = true ? "1.100.1" : "0.0.0-dev";
4770
+ KERNEL_VERSION = true ? "1.100.3" : "0.0.0-dev";
4771
4771
  OS_RELEASE = "6.0.0-slicc";
4772
4772
  }
4773
4773
  });
package/dist/node.js CHANGED
@@ -11107,7 +11107,7 @@ var PATH_OPS = new Set(SYNC_FS_OPS);
11107
11107
  var EARLY_WHOLE_FILE = 64 * 1024;
11108
11108
 
11109
11109
  // src/version.ts
11110
- var KERNEL_VERSION = true ? "1.100.1" : "0.0.0-dev";
11110
+ var KERNEL_VERSION = true ? "1.100.3" : "0.0.0-dev";
11111
11111
  var OS_RELEASE = "6.0.0-slicc";
11112
11112
  function procVersion() {
11113
11113
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -14246,6 +14246,13 @@ var SEM_NAMES_MAX = 4096;
14246
14246
  var SEM_HANDLES_MAX = 256;
14247
14247
  var NAME_MAX = 251;
14248
14248
  var TIMER_MAX_MS = 2147483647;
14249
+ var deadlines = /* @__PURE__ */ new WeakMap();
14250
+ function timeLeft(req, timeoutMs) {
14251
+ const now = performance.now();
14252
+ const deadline = deadlines.get(req) ?? now + timeoutMs;
14253
+ deadlines.set(req, deadline);
14254
+ return Math.max(0, deadline - now);
14255
+ }
14249
14256
  var SEM_OPS = [
14250
14257
  "sem-open",
14251
14258
  "sem-close",
@@ -14432,8 +14439,9 @@ async function semSyscall(req, proc) {
14432
14439
  const sem = handles.get(req.handle);
14433
14440
  if (sem.take()) return ok2();
14434
14441
  if (req.how === "try") throw new KernelError("EAGAIN");
14435
- if (req.how === "timed" && req.timeoutMs === 0) throw new KernelError("ETIMEDOUT");
14436
- const got = await sem.wait(proc.blocking(), req.how === "block" ? -1 : req.timeoutMs);
14442
+ const timeoutMs = req.how === "block" ? -1 : timeLeft(req, req.timeoutMs);
14443
+ if (timeoutMs === 0) throw new KernelError("ETIMEDOUT");
14444
+ const got = await sem.wait(proc.blocking(), timeoutMs);
14437
14445
  if (!got) throw new KernelError("ETIMEDOUT");
14438
14446
  return ok2();
14439
14447
  }
@@ -15456,6 +15464,10 @@ function identityKey(st, path) {
15456
15464
  }
15457
15465
  var DYING = { ok: false, errno: "EINTR", message: "the process is being killed" };
15458
15466
  var HOSTS_ONLY = new Resolver({ routes: new Routes() });
15467
+ function timeLeft2(req, started) {
15468
+ if (!("timeoutMs" in req) || typeof req.timeoutMs !== "number" || req.timeoutMs < 0) return req;
15469
+ return { ...req, timeoutMs: Math.max(0, req.timeoutMs - (performance.now() - started)) };
15470
+ }
15459
15471
  var WasmProcess = class {
15460
15472
  exited = false;
15461
15473
  children;
@@ -15616,22 +15628,28 @@ var WasmProcess = class {
15616
15628
  blocks = /* @__PURE__ */ new WeakMap();
15617
15629
  async syscall(req, cancelled, block) {
15618
15630
  this.options.onSyscall?.(req);
15631
+ const started = performance.now();
15632
+ let restarted = false;
15619
15633
  for (; ; ) {
15620
15634
  await this.resumed;
15621
15635
  if (this.dying) return DYING;
15636
+ const current = restarted ? timeLeft2(req, started) : req;
15622
15637
  const stops = this.stops;
15623
15638
  const scope = new AbortController();
15624
15639
  const forward = () => scope.abort();
15625
15640
  if (cancelled?.aborted) scope.abort();
15626
15641
  cancelled?.addEventListener("abort", forward, { once: true });
15627
15642
  if (block) this.blocks.set(scope.signal, block);
15628
- const result = await this.dispatch(req, scope.signal).finally(() => {
15643
+ const result = await this.dispatch(current, scope.signal).finally(() => {
15629
15644
  cancelled?.removeEventListener("abort", forward);
15630
15645
  this.waiting.delete(scope.signal);
15631
15646
  });
15632
15647
  if (this.dying) return DYING;
15633
15648
  const restart = !result.ok && result.errno === "EINTR" && this.stops !== stops;
15634
- if (restart && !this.options.hasPending?.()) continue;
15649
+ if (restart && !this.options.hasPending?.() && req.op !== "epoll-wait") {
15650
+ restarted = true;
15651
+ continue;
15652
+ }
15635
15653
  await this.resumed;
15636
15654
  return result;
15637
15655
  }