diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-09 02:14:21 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-09 02:21:58 -0300 |
| commit | bfb74e76ef7dfe305a26010edc86dac456034c3e (patch) | |
| tree | c90744aa2e0edf37c8e6cbc0033476230a086412 /src/replica.zig | |
| parent | c78d362fa20393621ac198861f891439f9d832e9 (diff) | |
| download | pardes-bfb74e76ef7dfe305a26010edc86dac456034c3e.tar.gz pardes-bfb74e76ef7dfe305a26010edc86dac456034c3e.zip | |
locality: single-caller helpers beside their caller: File's placeOf and restoreName beside undoStep, Query's row makers (clearPlaces, makeAllRows, makeNameRows, feedGrepPlaces) beside produce, look's helpers beside lookAt, lookSpanIn and lookUnresolved, mouse's beside handleMouse and dragUpdate, normal's beside handleNormal and executeNormalAction, and the rest in Core, draw, exec, layout, main, modal, replica, syntax, terminal; Messages.printRight into draw.zig beside joinNotice and edit.spanHas into exec.zig beside operandAt, their only callers
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/replica.zig')
| -rw-r--r-- | src/replica.zig | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/replica.zig b/src/replica.zig index 1499d166..b88b1328 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -56,17 +56,6 @@ const unit_head = head_len + 16; pub const Unit = struct { origin: u16, seq: u32, real_ns: i64 = 0, mono_ns: i64 = 0, tape: []const u8 }; -pub fn parseUnit(msg: []const u8) ?Unit { - if (msg.len < unit_head) return null; - return .{ - .origin = std.mem.readInt(u16, msg[0..2], .little), - .seq = std.mem.readInt(u32, msg[2..6], .little), - .real_ns = std.mem.readInt(i64, msg[6..14], .little), - .mono_ns = std.mem.readInt(i64, msg[14..22], .little), - .tape = msg[unit_head..], - }; -} - fn clockNs(id: std.c.clockid_t) i64 { var ts: std.c.timespec = undefined; if (std.c.clock_gettime(id, &ts) != 0) return 0; @@ -626,6 +615,17 @@ const Pending = struct { seq: u32, msg: []u8, spec: ?[]u8 = null, sent_ns: u64 = /// units it shows, so those before it are not replayed over it. const View = struct { at: ?usize = null, after: usize = 0 }; +pub fn parseUnit(msg: []const u8) ?Unit { + if (msg.len < unit_head) return null; + return .{ + .origin = std.mem.readInt(u16, msg[0..2], .little), + .seq = std.mem.readInt(u32, msg[2..6], .little), + .real_ns = std.mem.readInt(i64, msg[6..14], .little), + .mono_ns = std.mem.readInt(i64, msg[14..22], .little), + .tape = msg[unit_head..], + }; +} + pub const Replica = struct { gpa: Allocator, id: u16, @@ -1484,17 +1484,6 @@ pub const Framer = struct { } }; -/// The process at the other end of unix socket `fd` (Linux's SO_PEERCRED), -/// or 0: a client's through ssh is ssh's. -fn peerPid(fd: c_int) libc.pid_t { - if (comptime builtin.os.tag != .linux) return 0; - const Cred = extern struct { pid: libc.pid_t, uid: libc.uid_t, gid: libc.gid_t }; - var cred: Cred = undefined; - var len: libc.socklen_t = @sizeOf(Cred); - if (libc.getsockopt(fd, libc.SOL.SOCKET, libc.SO.PEERCRED, &cred, &len) != 0) return 0; - return cred.pid; -} - pub const Peer = struct { peers: *Peers, fd: c_int, @@ -1814,6 +1803,17 @@ pub fn dying() void { }; } +/// The process at the other end of unix socket `fd` (Linux's SO_PEERCRED), +/// or 0: a client's through ssh is ssh's. +fn peerPid(fd: c_int) libc.pid_t { + if (comptime builtin.os.tag != .linux) return 0; + const Cred = extern struct { pid: libc.pid_t, uid: libc.uid_t, gid: libc.gid_t }; + var cred: Cred = undefined; + var len: libc.socklen_t = @sizeOf(Cred); + if (libc.getsockopt(fd, libc.SOL.SOCKET, libc.SO.PEERCRED, &cred, &len) != 0) return 0; + return cred.pid; +} + pub const Peers = struct { gpa: Allocator = std.heap.c_allocator, io: std.Io = undefined, |
