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;