[PATCH] Save/restore h_errno in getaddrinfo()
Stan Shebs
stanshebs@google.com
Tue Jul 12 22:29:00 GMT 2016
Recently, a bunch of service requests in the middle of Google's mighty
stack started failing, and it was tracked down to a situation where a
program would run out of file descriptors, then getaddrinfo() would
fail, but even after the file descriptors were closed and freed up,
getaddrinfo() would continue to return an error.
It turns out that subroutines of getaddrinfo() set h_errno to negative
values, and higher-level code such as gaih_inet tests it, but there is
nobody to reset it, so a negative value persists and then causes later
getaddrinfo calls to report an error even though everything works
fine.
Technically, there is probably a mistake in the bowels of resolver
code where the caller should recognize that the call has not failed,
and so h_error should not be looked at. However, as I understand the
documentation, getaddrinfo should not be touching h_errno anyway,
unless there is an error return. So I'm proposing a patch that simply
saves h_errno, clears it internally, and then restores it if
getaddrinfo succeeds.
2016-07-12 Stan Shebs <stanshebs@google.com>
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Save/restore h_errno.
* posix/tst-getaddrinfo6.c: New test.
* posix/Makefile (tests): Add tst-getaddrinfo6.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gai-patch
Type: application/octet-stream
Size: 4737 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160712/79bb7909/attachment.obj>
More information about the Libc-alpha
mailing list