Support gethostbyname_r_ERANGE.
[android-sdk/platform-bionic.git] / libc / dns / net / nsdispatch.c
index fb6d8f6ab0ee4949d405e7dd87e90b5f09c360cd..d025592a0473a101d9b05e929d91f64dba83e497 100644 (file)
@@ -71,6 +71,7 @@
 #include <sys/cdefs.h>
 
 #include <assert.h>
+#include <errno.h>
 #include <nsswitch.h>
 #include <stdarg.h>
 #include <strings.h>
@@ -133,6 +134,10 @@ nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
                                continue;
                        if (result & srclist[i].flags)
                                break;
+                       /* Stop trying next resolver when there is a memory space fatal error. */
+                       if ((result & NS_UNAVAIL) != 0 && errno == ENOSPC) {
+                         break;
+                       }
                }
        }
        result &= NS_STATUSMASK;        /* clear private flags in result */