Up to [cvs.NetBSD.org] / src / lib / libc / resolv
Request diff between arbitrary revisions
Default branch: MAIN
Current tag: HEAD
Revision 1.32 / (download) - annotate - [selected], Thu Sep 30 12:35:55 2021 UTC (7 months, 3 weeks ago) by christos
Branch: MAIN
CVS Tags: HEAD
Changes since 1.31: +28 -14
lines
Diff to previous 1.31 (unified)
kqueue(2) file descriptors are not inherited across fork(2). A process that that calls getaddrinfo(3) will end up cacheing the kqueue(2) file descriptor in its res_state structure. If that process fork(2)s and calls getaddrinfo(3) again might end up closing that cached file descriptor which can end up pointing to a different file object than the kqueue(2) original one. To fix this, associate the kqueue(2) file descriptor with the process id that created it, and don't close(2) it if it is being closed from a different process. An alternative fix would be to attach the resolver to a fork(2) hook to cleanup the res_state, but handling it internally in the resolver is less intrusive. This was discovered by Dima Veselov when using the FreeRADIUS package.