Skip to content

Commit e6d46f6

Browse files
committed
watcher/async: use mach_port_destroy for mach ports
1 parent 4f98f5c commit e6d46f6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/watcher/async.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ fn AsyncMachPort(comptime xev: type) type {
146146
info: *anyopaque,
147147
count: posix.system.mach_msg_type_number_t,
148148
) posix.system.kern_return_t;
149+
extern "c" fn mach_port_destroy(
150+
task: posix.system.ipc_space_t,
151+
name: posix.system.mach_port_name_t,
152+
) posix.system.kern_return_t;
149153

150154
/// The mach port
151155
port: posix.system.mach_port_name_t,
@@ -165,7 +169,7 @@ fn AsyncMachPort(comptime xev: type) type {
165169
.SUCCESS => {}, // Success
166170
else => return error.MachPortAllocFailed,
167171
}
168-
errdefer _ = posix.system.mach_port_deallocate(mach_self, mach_port);
172+
errdefer _ = posix.system.mach_port_destroy(mach_self, mach_port);
169173

170174
// Insert a send right into the port since we also use this to send
171175
switch (posix.system.getKernError(posix.system.mach_port_insert_right(
@@ -200,7 +204,7 @@ fn AsyncMachPort(comptime xev: type) type {
200204
/// Clean up the async. This will forcibly deinitialize any resources
201205
/// and may result in erroneous wait callbacks to be fired.
202206
pub fn deinit(self: *Self) void {
203-
_ = posix.system.mach_port_deallocate(
207+
_ = mach_port_destroy(
204208
posix.system.mach_task_self(),
205209
self.port,
206210
);

0 commit comments

Comments
 (0)