summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Addon.zig18
-rw-r--r--core/Effect.zig7
-rw-r--r--core/Kind.zig2
-rw-r--r--core/tape.zig3
4 files changed, 23 insertions, 7 deletions
diff --git a/core/Addon.zig b/core/Addon.zig
index c60f2430..aa3195f9 100644
--- a/core/Addon.zig
+++ b/core/Addon.zig
@@ -567,9 +567,11 @@ pub fn loadedOf(ops: *const Kind.Ops, path: []const u8, hash: [32]u8, words: *[6
/// This process's code for a kind a session's core lists, which a client
/// runs itself: PA_PLAIN, of the same name, version, ABI and functions (a
-/// compiled-in addon's library hash is 0: never by the hash), and not
-/// caught breaking its promise here (`distrusted`, the client's). Null: its
-/// panes say so.
+/// compiled-in addon's library hash is 0: never by the hash), or else the
+/// library at the session's path when its bytes are the session's (P51: a
+/// client on its machine; never bytes the session sent), and not caught
+/// breaking its promise here (`distrusted`, the client's). Null: its panes
+/// say so.
pub fn plainOps(e: *const Kind.Entry, distrusted: ?*const Distrusted) ?*const Kind.Ops {
if (!e.caps.plain or e.refused) return null;
// A client scans for its addons only when its session has a plain kind.
@@ -582,6 +584,16 @@ pub fn plainOps(e: *const Kind.Entry, distrusted: ?*const Distrusted) ?*const Ki
if (l.ops == 0) l.ops = loadListed(i, &why) orelse return null;
return @ptrFromInt(l.ops);
};
+ var words: [64]LoadedWord = undefined;
+ var why: Why = .{};
+ var data_buf: [4096]u8 = undefined;
+ const l = read(dataDir(&data_buf), e.path.slice(), &words, &why);
+ if (l.why.len > 0) return null;
+ const ops: *const Kind.Ops = @ptrFromInt(l.ops);
+ if (std.mem.eql(u8, &l.hash, &e.hash)) return ops;
+ const lib = libOf(ops).?;
+ lib.refs -= 1;
+ closeIdle(lib);
return null;
}
diff --git a/core/Effect.zig b/core/Effect.zig
index cabfe8ea..9fb4d9fa 100644
--- a/core/Effect.zig
+++ b/core/Effect.zig
@@ -251,9 +251,10 @@ fn performInner(p: *Pardes, e: Effect) void {
.dump_themes => |d| _ = p.tape.host(p, .dump_themes, .{d.pane}),
.detach => |d| p.tape.host(p, .detach, .{}) orelse p.reportError(d.pane, "detach", error.NotAttached),
// dlopen is the same on every host, so none has a method of its
- // own; a replica's core holds no library (what it brought comes in
- // the event this taped).
- .addon => |a| if (!p.tape.replaying()) @import("Addon.zig").perform(p, a.op, a.pane.index(), a.arg.slice()),
+ // own; a replica's core holds no library: what it brought is the
+ // event inside this call, recorded there and applied by a replay
+ // (its code a client's own, Addon.plainOps); a speculation waits.
+ .addon => |a| if (!p.tape.authorityOnly("an addon's load")) p.tape.value(.landing, @import("Addon.zig").perform, .{ p, a.op, a.pane.index(), a.arg.slice() }),
.job => |j| p.tape.host(p, .job, .{ j.pane, j.serial, j.token }) orelse if (!p.tape.replaying()) host_io.KindJob.runHere(p, j.pane.index(), j.serial, j.token),
// the loop's own condition; a host tears down after its own loop
.quit => p.endSession(),
diff --git a/core/Kind.zig b/core/Kind.zig
index 81997afb..49076f78 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -424,7 +424,7 @@ pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pa
if (slot.ops == null and slot.live) {
// A client: a plain kind runs where it is shown, and this one lacks
// it; any other runs in its session alone.
- const why = if (caps(p, slot).plain) "it is not in its addons, or it broke its promise here" else "its state is not plain (PA_PLAIN), so it runs in the session alone";
+ const why = if (caps(p, slot).plain) "it is not in its addons nor the session's library at its path here, or it broke its promise here" else "its state is not plain (PA_PLAIN), so it runs in the session alone";
var line: [200]u8 = undefined;
_ = s.print(x, y, cols, std.fmt.bufPrint(&line, "addon {s} {d} does not run in this client: {s}", .{ slot.nameOf(), slot.version, why }) catch &line, .{ .fg = fg, .bg = bg });
return;
diff --git a/core/tape.zig b/core/tape.zig
index d1e0527c..ced29e6a 100644
--- a/core/tape.zig
+++ b/core/tape.zig
@@ -140,6 +140,9 @@ pub const Site = enum(u16) {
/// A kitty image's medium as a terminal's emulator read it (a file, a
/// temporary file, shared memory: Term.media), its bytes or its failure.
medium,
+ /// An addon's library loaded or let go (Addon.perform): what it brought
+ /// is the `addon` event inside it, which a replica applies from here.
+ landing,
};
/// What the sites return. wire.semantics hashes their shape with the