summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/replica.zig b/src/replica.zig
index 8bc27256..0adadb7e 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -1408,12 +1408,6 @@ pub const Framer = struct {
}
};
-fn readFramed(gpa: Allocator, fd: c_int, ctx: anytype, comptime take: fn (@TypeOf(ctx), u8, []const u8) bool) void {
- var fr: Framer = .{};
- defer fr.deinit(gpa);
- fr.run(gpa, fd, ctx, take);
-}
-
pub const Peer = struct {
peers: *Peers,
fd: c_int,
@@ -1702,7 +1696,10 @@ pub const Peer = struct {
}
fn readLoop(peer: *Peer) void {
- readFramed(peer.peers.gpa, peer.fd, peer, take);
+ // The framer goes before `gone`, after which the peer may be freed.
+ var fr: Framer = .{};
+ fr.run(peer.peers.gpa, peer.fd, peer, take);
+ fr.deinit(peer.peers.gpa);
peer.peers.post(.{ .gone = peer });
}
};
@@ -2252,7 +2249,7 @@ pub const Joined = struct {
/// Its build's (wire.semantics): the daemon judged the hello by what it
/// last heard, which an upgrade under way may not have said yet.
semantics: u64 = 0,
- /// What was read past the dump: the stream's (`readStream`).
+ /// What was read past the dump: the stream's (`readLink`).
rest: Framer = .{},
/// A far join's blobs that came over the link, for `Have.store` (the C
/// heap's), and how it went: its blobs, those it held already (from the
@@ -2731,13 +2728,6 @@ pub fn bye(fd: c_int, again: bool) void {
if (wire.encodeClient(&out, .{ .bye = .{ .again = again } })) |b| _ = writeAll(fd, b) else |_| {}
}
-/// What follows the dump on the client's connection, each message handed
-/// to `take` (a unit, a terminal's delta) until the link ends; `rest` is
-/// what the dump's reader read past it.
-pub fn readStream(gpa: Allocator, fd: c_int, rest: *Framer, ctx: anytype, comptime take: fn (@TypeOf(ctx), u8, []const u8) bool) void {
- rest.run(gpa, fd, ctx, take);
-}
-
/// What the session streams a client after its dump, as its frontend's loop
/// takes it: a unit's and a terminal message's bytes and a refusal's words
/// on the C heap, the loop's to free.