]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- Removed IP_BLOCKING_LOOKUP and FQDN_BLOCKING_LOOKUP flags. All DNS
authorwessels <>
Tue, 28 Oct 1997 05:48:55 +0000 (05:48 +0000)
committerwessels <>
Tue, 28 Oct 1997 05:48:55 +0000 (05:48 +0000)
  lookups must now be non-blocking.
- Don't queue something to a dnsserver if it is DNS_FLAG_CLOSING.
- Call an IP cache entry expired if addrs.count == 0.

src/defines.h
src/fqdncache.cc
src/ipcache.cc

index 3dce0fb78824016ab76e13f65722036732ebc153..0f70c013982e3397b6a5e5270b743cd02f725cf5 100644 (file)
@@ -71,7 +71,7 @@
 
 #define FD_DESC_SZ             64
 
-#define FQDN_BLOCKING_LOOKUP   0x01
+#define FQDN_FLAG_UNUSED_01    0x01
 #define FQDN_LOOKUP_IF_MISS    0x02
 
 #define FQDN_MAX_NAMES 5
 #define IDENT_PENDING 1
 #define IDENT_DONE 2
 
-#define IP_BLOCKING_LOOKUP     0x01
+#define IP_UNUSED_FLAG_01      0x01
 #define IP_LOOKUP_IF_MISS      0x02
 
 #define IPCACHE_AV_FACTOR 1000
index ee32a85349b5807945b3ee2f45e96751995fd4eb..d58519c3ea0d86ed9c25c0183cf2d97ea7a2a7f1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.61 1997/10/25 17:22:41 wessels Exp $
+ * $Id: fqdncache.cc,v 1.62 1997/10/27 22:48:56 wessels Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -667,14 +667,12 @@ fqdncache_nbgethostbyaddr(struct in_addr addr, FQDNH * handler, void *handlerDat
 
     if ((dnsData = dnsGetFirstAvailable())) {
        fqdncache_dnsDispatch(dnsData, f);
-       return;
-    }
-    if (NDnsServersAlloc > 0) {
+    } else if (NDnsServersAlloc > 0) {
        fqdncacheEnqueue(f);
-       return;
+    } else {
+       /* abort if we get here */
+       assert(NDnsServersAlloc);
     }
-    fqdncache_gethostbyaddr(addr, FQDN_BLOCKING_LOOKUP);
-    fqdncache_call_pending(f);
 }
 
 static void
@@ -693,7 +691,7 @@ fqdncache_dnsDispatch(dnsserver_t * dns, fqdncache_entry * f)
     if (f->status != FQDN_PENDING)
        debug_trap("fqdncache_dnsDispatch: status != FQDN_PENDING");
     buf = xcalloc(1, 256);
-    snprintf(buf, 256, "%1.254s\n", f->name);
+    snprintf(buf, 256, "s\n", f->name);
     dns->flags |= DNS_FLAG_BUSY;
     dns->data = f;
     f->status = FQDN_DISPATCHED;
@@ -778,12 +776,7 @@ fqdncache_gethostbyaddr(struct in_addr addr, int flags)
        }
     }
     if (f) {
-       if (f->status == FQDN_PENDING || f->status == FQDN_DISPATCHED) {
-           if (!BIT_TEST(flags, IP_BLOCKING_LOOKUP)) {
-               FqdncacheStats.pending_hits++;
-               return NULL;
-           }
-       } else if (f->status == FQDN_NEGATIVE_CACHED) {
+       if (f->status == FQDN_NEGATIVE_CACHED) {
            FqdncacheStats.negative_hits++;
            dns_error_message = f->error_message;
            return NULL;
@@ -797,33 +790,6 @@ fqdncache_gethostbyaddr(struct in_addr addr, int flags)
     if (!safe_inet_addr(name, &ip))
        return name;
     FqdncacheStats.misses++;
-    if (BIT_TEST(flags, FQDN_BLOCKING_LOOKUP)) {
-       if (NDnsServersAlloc)
-           debug(14, 0) ("WARNING: blocking on gethostbyaddr() for '%s'\n", name);
-       FqdncacheStats.ghba_calls++;
-       hp = gethostbyaddr((char *) &ip.s_addr, 4, AF_INET);
-       if (hp && hp->h_name && (hp->h_name[0] != '\0') && fqdn_table) {
-           if (f == NULL) {
-               f = fqdncacheAddNew(name, hp, FQDN_CACHED);
-           } else if (f->status == FQDN_DISPATCHED) {
-               /* only dnsHandleRead() can change from DISPATCHED to CACHED */
-               xfree(static_name);
-               static_name = xstrdup(hp->h_name);
-               return static_name;
-           } else {
-               fqdncacheAddHostent(f, hp);
-               f->status = FQDN_CACHED;
-           }
-           f->expires = squid_curtime + Config.positiveDnsTtl;
-           return f->names[0];
-       }
-       /* bad address, negative cached */
-       if (fqdn_table && f == NULL) {
-           f = fqdncacheAddNew(name, hp, FQDN_NEGATIVE_CACHED);
-           f->expires = squid_curtime + Config.negativeDnsTtl;
-           return NULL;
-       }
-    }
     if (flags & FQDN_LOOKUP_IF_MISS)
        fqdncache_nbgethostbyaddr(addr, dummy_handler, NULL);
     return NULL;
index 4d9eb68349c83e7081dc97736ff5f31aecd91d30..62003f41ffb5456d62809010089714f7b8278864 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.137 1997/10/27 03:12:12 wessels Exp $
+ * $Id: ipcache.cc,v 1.138 1997/10/27 22:48:56 wessels Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -327,12 +327,10 @@ ipcacheExpiredEntry(ipcache_entry * i)
        return 0;
     if (i->locks != 0)
        return 0;
+    if (i->addrs.count == 0)
+       return 1;
     if (i->expires > squid_curtime)
        return 0;
-    if (i->status == IP_CACHED)
-       if (squid_curtime - i->lastref < 60)
-           if (i->addrs.count > 0)
-               return 0;
     return 1;
 }
 
@@ -717,14 +715,12 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
 
     if ((dnsData = dnsGetFirstAvailable())) {
        ipcache_dnsDispatch(dnsData, i);
-       return;
-    }
-    if (NDnsServersAlloc) {
+    } else if (NDnsServersAlloc) {
        ipcacheEnqueue(i);
-       return;
+    } else {
+       /* generate abort if we get here */
+       assert(NDnsServersAlloc);
     }
-    ipcache_gethostbyname(name, IP_BLOCKING_LOOKUP);
-    ipcache_call_pending(i);
 }
 
 static void
@@ -741,7 +737,7 @@ ipcache_dnsDispatch(dnsserver_t * dns, ipcache_entry * i)
     }
     assert(i->status == IP_PENDING);
     buf = xcalloc(1, 256);
-    snprintf(buf, 256, "%1.254s\n", i->name);
+    snprintf(buf, 256, "%s\n", i->name);
     dns->flags |= DNS_FLAG_BUSY;
     dns->data = i;
     i->status = IP_DISPATCHED;
@@ -832,12 +828,7 @@ ipcache_gethostbyname(const char *name, int flags)
        }
     }
     if (i) {
-       if (i->status == IP_PENDING || i->status == IP_DISPATCHED) {
-           if (!BIT_TEST(flags, IP_BLOCKING_LOOKUP)) {
-               IpcacheStats.pending_hits++;
-               return NULL;
-           }
-       } else if (i->status == IP_NEGATIVE_CACHED) {
+       if (i->status == IP_NEGATIVE_CACHED) {
            IpcacheStats.negative_hits++;
            dns_error_message = i->error_message;
            return NULL;
@@ -850,43 +841,6 @@ ipcache_gethostbyname(const char *name, int flags)
     if ((addrs = ipcacheCheckNumeric(name)))
        return addrs;
     IpcacheStats.misses++;
-    if (BIT_TEST(flags, IP_BLOCKING_LOOKUP)) {
-       if (NDnsServersAlloc)
-           debug(14, 0) ("WARNING: blocking on gethostbyname() for '%s'\n", name);
-       IpcacheStats.ghbn_calls++;
-       hp = gethostbyname(name);
-       if (hp && hp->h_name && (hp->h_name[0] != '\0') && ip_table) {
-           /* good address, cached */
-           if (i == NULL) {
-               i = ipcacheAddNew(name, hp, IP_CACHED);
-           } else if (i->status == IP_DISPATCHED) {
-               /* only dnsHandleRead() can change from DISPATCHED to CACHED */
-               static_addrs.count = 1;
-               static_addrs.cur = 0;
-               static_addrs.badcount = 0;
-               static_addrs.bad_mask[0] = FALSE;
-               xmemcpy(&static_addrs.in_addrs[0].s_addr,
-                   *(hp->h_addr_list),
-                   hp->h_length);
-               return &static_addrs;
-           } else {
-               ipcacheAddHostent(i, hp);
-               i->status = IP_CACHED;
-           }
-           i->expires = squid_curtime + Config.positiveDnsTtl;
-#if LIBRESOLV_DNS_TTL_HACK
-           if (_dns_ttl_ > -1)
-               i->expires = squid_curtime + _dns_ttl_;
-#endif /* LIBRESOLV_DNS_TTL_HACK */
-           return &i->addrs;
-       }
-       /* bad address, negative cached */
-       if (ip_table && i == NULL) {
-           i = ipcacheAddNew(name, hp, IP_NEGATIVE_CACHED);
-           i->expires = squid_curtime + Config.negativeDnsTtl;
-           return NULL;
-       }
-    }
     if (flags & IP_LOOKUP_IF_MISS)
        ipcache_nbgethostbyname(name, dummy_handler, NULL);
     return NULL;
@@ -1092,7 +1046,7 @@ ipcacheMarkBadAddr(const char *name, struct in_addr addr)
     if (!ia->bad_mask[k]) {
        ia->bad_mask[k] = TRUE;
        ia->badcount++;
-       debug(14, 1) ("ipcacheMarkBad: %s [%s]\n",
+       debug(14, 2) ("ipcacheMarkBadAddr: %s [%s]\n",
            name, inet_ntoa(ia->in_addrs[k]));
        if (ia->badcount != ia->count) {
            /* at least one good address left */
@@ -1127,7 +1081,7 @@ ipcacheMarkGoodAddr(const char *name, struct in_addr addr)
        ia->bad_mask[k] = FALSE;
        ia->badcount--;
        i->expires = squid_curtime + Config.positiveDnsTtl;
-       debug(14, 1) ("ipcacheMarkGoodAddr: %s [%s]\n",
+       debug(14, 2) ("ipcacheMarkGoodAddr: %s [%s]\n",
            name, inet_ntoa(ia->in_addrs[k]));
     }
 }