From 41147087343144a439a77e6b9817f30d596a6fcb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 17:24:55 -0300 Subject: A pane refused for want of room spends no pane serial, as a refused Newcol spends no column serial A pane/new, look or exec refused ENOSPC made its pane before placing it. The refusal closed the pane unannounced, but its serial was gone, so the next pane skipped one. When sync removes a refused pane that holds the newest serial, it now puts the counter back. Co-Authored-By: Claude Opus 5.5 --- src/ninep/tree.zig | 4 ++++ src/pardes.zig | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 322728da..53d33731 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1861,6 +1861,10 @@ test "no placement leaves a pane shorter than its tag and two rows; a full colum } else return error.NeverRefused; try testing.expectEqual(E.NOSPC, refused.errno()); try testing.expect(std.mem.indexOf(u8, refused.reply.ename, "no space for a pane in that column") != null); + // The refused pane was never there: no serial spent on it. + const before = p.next_serial; + try testing.expectEqual(E.NOSPC, call(p, .{ .tag = 1, .op = .open, .node = new }).errno()); + try testing.expectEqual(before, p.next_serial); p.sync(); var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); diff --git a/src/pardes.zig b/src/pardes.zig index 3a6e154a..dc2ec59f 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -6995,7 +6995,13 @@ pub const Pardes = struct { var refused = false; while (p.unplaced.findFirstSet()) |id| { p.unplaced.unset(id); - if (p.panes[id] != null) p.removePane(id, null) catch {}; + if (p.panes[id]) |pane| { + // Refused, it was never there: the serial it took is the + // next pane's, as a refused Newcol's column serial is. + const newest = pane.serial == p.next_serial; + p.removePane(id, null) catch {}; + if (newest and p.panes[id] == null) p.next_serial -= 1; + } refused = true; } // A refused pane gone, no pane it squeezed stays under its minimum. -- cgit v1.3