summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-02 00:25:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-02 00:25:33 +0000
commit9f92e30632936d18bca2ab703f171bb77f66abde (patch)
tree0b7e675f3cf70a98564a6422c095eae9a9fdd2ab /libc
parent2ac83a8051148f4f1395795573ab12f317595837 (diff)
resolver: reinstate searching if search domains accidentally nuked
in one of recent commits :)
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/resolv.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index f73329a92..044059d7d 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -754,8 +754,9 @@ static uint16_t static_id = 1;
* a.rdata: points into *outpacket to 1st IP addr
* NB: don't pass outpacket == NULL if you need to use a.rdata!
* a.atype: type of query?
- * a.dotted: numeric IP as a string (malloced, may be NULL if strdup failed)
- * (which one of potentially many??)
+ * a.dotted: which name we _actually_ used. May contain search domains
+ * appended. (why the filed is called "dotted" I have no idea)
+ * This is a malloced string. May be NULL because strdup failed.
*/
int attribute_hidden __dns_lookup(const char *name, int type,
int nscount, char **nsip,
@@ -953,6 +954,18 @@ int attribute_hidden __dns_lookup(const char *name, int type,
if (h.rcode == NXDOMAIN) {
// bug 660 says we treat negative response as an error and retry
// which is, eh, an error. :) We were incurring long delays because of this.
+ /* if possible, try next search domain */
+ if (!ends_with_dot) {
+ int sdomains;
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ sdomains = __searchdomains;
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ if (variant < sdomains - 1) {
+ /* next search */
+ variant++;
+ continue;
+ }
+ }
/* this is not an error - don't goto again! */
h_errno = HOST_NOT_FOUND;
goto fail1;
@@ -1055,11 +1068,9 @@ int attribute_hidden __dns_lookup(const char *name, int type,
/* if there are searchdomains, try them or fallback as passed */
if (!ends_with_dot) {
int sdomains;
-
__UCLIBC_MUTEX_LOCK(__resolv_lock);
sdomains = __searchdomains;
__UCLIBC_MUTEX_UNLOCK(__resolv_lock);
-
if (variant < sdomains - 1) {
/* next search */
variant++;