From e6d46f66d224584529be842007ead7e1e4153dc3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 1 Aug 2024 10:26:33 -0700 Subject: [PATCH] watcher/async: use mach_port_destroy for mach ports --- src/watcher/async.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/watcher/async.zig b/src/watcher/async.zig index 910470d..ddd30f6 100644 --- a/src/watcher/async.zig +++ b/src/watcher/async.zig @@ -146,6 +146,10 @@ fn AsyncMachPort(comptime xev: type) type { info: *anyopaque, count: posix.system.mach_msg_type_number_t, ) posix.system.kern_return_t; + extern "c" fn mach_port_destroy( + task: posix.system.ipc_space_t, + name: posix.system.mach_port_name_t, + ) posix.system.kern_return_t; /// The mach port port: posix.system.mach_port_name_t, @@ -165,7 +169,7 @@ fn AsyncMachPort(comptime xev: type) type { .SUCCESS => {}, // Success else => return error.MachPortAllocFailed, } - errdefer _ = posix.system.mach_port_deallocate(mach_self, mach_port); + errdefer _ = posix.system.mach_port_destroy(mach_self, mach_port); // Insert a send right into the port since we also use this to send switch (posix.system.getKernError(posix.system.mach_port_insert_right( @@ -200,7 +204,7 @@ fn AsyncMachPort(comptime xev: type) type { /// Clean up the async. This will forcibly deinitialize any resources /// and may result in erroneous wait callbacks to be fired. pub fn deinit(self: *Self) void { - _ = posix.system.mach_port_deallocate( + _ = mach_port_destroy( posix.system.mach_task_self(), self.port, );