diff options
Diffstat (limited to 'src/replica.zig')
| -rw-r--r-- | src/replica.zig | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/replica.zig b/src/replica.zig index 32fd4fbe..02141f44 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -2646,7 +2646,7 @@ pub const Link = struct { if (c.notice_len > 0 and (ev == .key or ev == .paste)) c.notice_len = 0; c.input_ns = nowNs(); const msg = c.r.input(ev) catch return; - if (!sendInput(c.fd, msg)) c.quit = true; + if (!sendInput(c.fd, msg)) c.cut(); c.dirty = true; } @@ -2667,9 +2667,7 @@ pub const Link = struct { }, .screen => |bytes| { defer std.heap.c_allocator.free(bytes); - if (c.r.screen(bytes)) |reply| if (!sendScreen(c.fd, reply)) { - c.quit = true; - }; + if (c.r.screen(bytes)) |reply| if (!sendScreen(c.fd, reply)) c.cut(); c.dirty = true; }, .checked => |d| c.checked(d), @@ -2693,11 +2691,18 @@ pub const Link = struct { } c.dirty = false; while (c.r.screenRequest()) |req| if (!sendScreen(c.fd, req)) { - c.quit = true; + c.cut(); break; }; } + /// A write to the session failed: it hung up (it cut this client off, + /// lagging), as its reader will say. + fn cut(c: *Link) void { + c.quit = true; + c.gone = true; + } + /// Each pass of the frontend's loop: quiet (nothing of its own /// pending) 300 ms after its last input and its last check, and /// changed since, the session's digest is asked once, answered in @@ -2711,6 +2716,7 @@ pub const Link = struct { if (since < quiet_ns) return @intCast((quiet_ns - since) / std.time.ns_per_ms + 1); c.changed = false; c.asked = askCheck(c.fd); + if (!c.asked) c.cut(); c.asked_ns = nowNs(); return null; } |
