File: [cvs.NetBSD.org] / src / lib / libc / resolv / res_private.h (download)
Revision 1.3.48.1, Tue Oct 5 11:06:58 2021 UTC (2 years, 6 months ago) by martin
Branch: netbsd-9
CVS Tags: netbsd-9-3-RELEASE Changes since 1.3: +2 -1
lines
Pull up following revision(s) (requested by christos in ticket #1356):
lib/libc/resolv/res_init.c: revision 1.32
lib/libc/resolv/res_private.h: revision 1.4
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.
|