mac: Update comment describing using Mach receive rights with kqueue()

The prohibition on using Mach receive rights with kqueue() was lifted in
10.12. Add the source code reference that should have been here all
along, and explain how xnu has changed. When the minimum runtime target
is 10.12 or later, the port set in this code will be unnecessary, and it
will be possible to remove it.

Change-Id: I8fdf91a124efb081e4748ccf60680b12a38c4d18
Reviewed-on: https://chromium-review.googlesource.com/c/1406894
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Mark Mentovai 2019-01-11 12:51:00 -05:00 committed by Commit Bot
parent dc6dee855e
commit eb3f371879

View File

@ -126,8 +126,12 @@ mach_port_t ChildPortHandshakeServer::RunServer(
return MACH_PORT_NULL;
}
// A kqueue cannot monitor a raw Mach receive right with EVFILT_MACHPORT. It
// requires a port set. Create a new port set and add the receive right to it.
// Prior to macOS 10.12, a kqueue cannot monitor a raw Mach receive right with
// EVFILT_MACHPORT. It requires a port set. Compare 10.11.6
// xnu-3248.60.10/osfmk/ipc/ipc_pset.c filt_machportattach(), which requires
// MACH_PORT_RIGHT_PORT_SET, to 10.12.0 xnu-3789.1.32/osfmk/ipc/ipc_pset.c
// filt_machportattach(), which also handles MACH_PORT_TYPE_RECEIVE. Create a
// new port set and add the receive right to it.
base::mac::ScopedMachPortSet server_port_set(
NewMachPort(MACH_PORT_RIGHT_PORT_SET));
CHECK(server_port_set.is_valid());