From 00140fcfe6728c3570dacf43b149e476079c68ec Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 14 Mar 2026 18:42:43 +0100 Subject: [PATCH] fix: make sure we release self.snapshots_mutex on errors --- src/backend/KQueue.zig | 1 + src/backend/KQueueDir.zig | 1 + 2 files changed, 2 insertions(+) diff --git a/src/backend/KQueue.zig b/src/backend/KQueue.zig index 68fbb74..a8f6d4d 100644 --- a/src/backend/KQueue.zig +++ b/src/backend/KQueue.zig @@ -386,6 +386,7 @@ fn take_snapshot(self: *@This(), allocator: std.mem.Allocator, dir_path: []const try names.append(allocator, try allocator.dupe(u8, entry.name)); } self.snapshots_mutex.lock(); + errdefer self.snapshots_mutex.unlock(); const gop = try self.snapshots.getOrPut(allocator, dir_path); if (!gop.found_existing) gop.value_ptr.* = .empty; var snapshot = gop.value_ptr; diff --git a/src/backend/KQueueDir.zig b/src/backend/KQueueDir.zig index ab20e68..8908ec0 100644 --- a/src/backend/KQueueDir.zig +++ b/src/backend/KQueueDir.zig @@ -331,6 +331,7 @@ fn take_snapshot(self: *@This(), allocator: std.mem.Allocator, dir_path: []const var dir = std.fs.openDirAbsolute(dir_path, .{ .iterate = true }) catch return; defer dir.close(); self.snapshots_mutex.lock(); + errdefer self.snapshots_mutex.unlock(); const gop = try self.snapshots.getOrPut(allocator, dir_path); if (!gop.found_existing) gop.value_ptr.* = .empty; const snapshot = gop.value_ptr;