Date: Sun, 15 Aug 2010 16:28:09 +0000 (UTC) From: Hajimu UMEMOTO <ume@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r211340 - head/lib/libc/net Message-ID: <201008151628.o7FGS9hX065434@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ume Date: Sun Aug 15 16:28:08 2010 New Revision: 211340 URL: http://svn.freebsd.org/changeset/base/211340 Log: Correct the return code from _dns_gethostby*() to correspond with h_errno. Obtained from: NetBSD MFC after: 2 weeks Modified: head/lib/libc/net/gethostbydns.c Modified: head/lib/libc/net/gethostbydns.c ============================================================================== --- head/lib/libc/net/gethostbydns.c Sun Aug 15 15:33:01 2010 (r211339) +++ head/lib/libc/net/gethostbydns.c Sun Aug 15 16:28:08 2010 (r211340) @@ -522,18 +522,26 @@ _dns_gethostbyname(void *rval, void *cb_ free(buf); dprintf("res_nsearch failed (%d)\n", n, statp); *h_errnop = statp->res_h_errno; - return (0); + return (NS_NOTFOUND); } else if (n > sizeof(buf->buf)) { free(buf); dprintf("static buffer is too small (%d)\n", n, statp); *h_errnop = statp->res_h_errno; - return (0); + return (NS_UNAVAIL); } error = gethostanswer(buf, n, name, type, &he, hed, statp); free(buf); if (error != 0) { *h_errnop = statp->res_h_errno; - return (NS_NOTFOUND); + switch (statp->res_h_errno) { + case HOST_NOT_FOUND: + return (NS_NOTFOUND); + case TRY_AGAIN: + return (NS_TRYAGAIN); + default: + return (NS_UNAVAIL); + } + /*NOTREACHED*/ } if (__copy_hostent(&he, hptr, buffer, buflen) != 0) { *errnop = errno; @@ -632,7 +640,15 @@ _dns_gethostbyaddr(void *rval, void *cb_ if (gethostanswer(buf, n, qbuf, T_PTR, &he, hed, statp) != 0) { free(buf); *h_errnop = statp->res_h_errno; - return (NS_NOTFOUND); /* h_errno was set by gethostanswer() */ + switch (statp->res_h_errno) { + case HOST_NOT_FOUND: + return (NS_NOTFOUND); + case TRY_AGAIN: + return (NS_TRYAGAIN); + default: + return (NS_UNAVAIL); + } + /*NOTREACHED*/ } free(buf); #ifdef SUNSECURITY
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008151628.o7FGS9hX065434>