auto import from //branches/cupcake/...@132276
diff --git a/libc/netbsd/resolv/res_send.c b/libc/netbsd/resolv/res_send.c
index 24b740a..3aca760 100644
--- a/libc/netbsd/resolv/res_send.c
+++ b/libc/netbsd/resolv/res_send.c
@@ -81,6 +81,9 @@
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+/* set to 1 to use our small/simple/limited DNS cache */
+#define  USE_RESOLV_CACHE  1
+
 /*
  * Send query to name server and wait for reply.
  */
@@ -111,6 +114,10 @@
 
 #include <isc/eventlib.h>
 
+#if USE_RESOLV_CACHE
+#  include <resolv_cache.h>
+#endif
+
 #ifndef DE_CONST
 #define DE_CONST(c,v)   v = ((c) ? \
     strchr((const void *)(c), *(const char *)(const void *)(c)) : NULL)
@@ -344,12 +351,17 @@
 	return (1);
 }
 
+
 int
 res_nsend(res_state statp,
 	  const u_char *buf, int buflen, u_char *ans, int anssiz)
 {
 	int gotsomewhere, terrno, try, v_circuit, resplen, ns, n;
 	char abuf[NI_MAXHOST];
+#if USE_RESOLV_CACHE
+        struct resolv_cache*  cache;
+        ResolvCacheStatus     cache_status = RESOLV_CACHE_UNSUPPORTED;
+#endif
 
 	if (statp->nscount == 0) {
 		errno = ESRCH;
@@ -365,6 +377,20 @@
 	gotsomewhere = 0;
 	terrno = ETIMEDOUT;
 
+#if USE_RESOLV_CACHE
+        cache = __get_res_cache();
+        if (cache != NULL) {
+            int  anslen = 0;
+            cache_status = _resolv_cache_lookup(
+                                cache, buf, buflen,
+                                ans, anssiz, &anslen);
+
+            if (cache_status == RESOLV_CACHE_FOUND) {
+                return anslen;
+            }
+        }
+#endif
+
 	/*
 	 * If the ns_addr_list in the resolver context has changed, then
 	 * invalidate our cached copy and the associated timing data.
@@ -534,6 +560,12 @@
 			(stdout, "%s", ""),
 			ans, (resplen > anssiz) ? anssiz : resplen);
 
+#if USE_RESOLV_CACHE
+                if (cache_status == RESOLV_CACHE_NOTFOUND) {
+                    _resolv_cache_add(cache, buf, buflen,
+                                      ans, resplen);
+                }
+#endif
 		/*
 		 * If we have temporarily opened a virtual circuit,
 		 * or if we haven't been asked to keep a socket open,