]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
merge from SQUID_1_0_10
authorwessels <>
Tue, 27 Aug 1996 01:56:55 +0000 (01:56 +0000)
committerwessels <>
Tue, 27 Aug 1996 01:56:55 +0000 (01:56 +0000)
13 files changed:
ChangeLog
include/util.h
lib/Makefile.in
src/acl.cc
src/cachemgr.cc
src/comm.cc
src/dnsserver.cc
src/http.cc
src/ipcache.cc
src/neighbors.cc
src/squid.h
src/ssl.cc
src/tunnel.cc

index cd1895e77d87409805553512a66908f9b6a377ac..bc1ccb17e675769fb90e8a3641db5c609cd8c36f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ Changes to squid-1.1.alpha12:
        - report all error pages to the debug log
        - Added -i option which forces IP cache entry to be invalidated
          just after an object retrieval begins.
+       - Includes all squid-1.0 changes up to squid-1.0.10.
 
 Changes to squid-1.1.alpha11:
 
@@ -116,6 +117,30 @@ Changes to squid-1.1.alpha2:
 
 ==============================================================================
 
+Changes to squid-1.0.10 (August 26, 1996):
+
+       - Fixed INADDR_NONE not being set for ftpget.c.
+       - Remove "Connection: Keep-Alive" lines from HTTP requests
+         since Squid doesn't support them.
+       - Fixed IP Address/netmask bug.  Now 1.2.3.4/255.255.255.0 is
+         equivalent to 1.2.3.0/255.255.255.0.
+
+Changes to squid-1.0.9 (August 22, 1996):
+
+       - Cleaned up ipcache_purgerlu().
+       - Fixed ipcache_gethostbyname() to release expired entries.
+       - Added check for numeric addresses to ipcache_nbgethostbyname().
+       - Added Date: field to ftpget's HTTP header output.
+       - Added temporary hack to httpProcessReplyHeaders() to allow
+         caching of non-HTTP objects fetched from neighbors when
+         the header does not have Date, Expires, or Last-Modified.
+       - Added a check for a valid ICP socket before sending ICP
+         queries.
+       - Fixed SSL code to unregister DNS lookups if client aborts.
+       - Removed lib/host_cache.c from distribution.
+       - Made IP cache stats output sorted by last reference.
+       - Added ICP internet-draft to docs directory.
+
 Changes to squid-1.0.8 (August 19, 1996):
 
        - Added ftpget fixes from carson@lehman.com and moy@parc.xerox.com.
index 3a651a7db2bcd7f7e71f5929ae4b7e54386a26d4..ee28cc6cdcd623f4b89e446ab5573fc0070e7c82 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: util.h,v 1.8 1996/07/22 16:41:04 wessels Exp $
+ * $Id: util.h,v 1.9 1996/08/26 19:56:59 wessels Exp $
  *
  * AUTHOR: Harvest Derived
  *
@@ -181,34 +181,6 @@ extern int Harvest_debug_levels[];
 #endif
 
 void debug_flag _PARAMS((char *));
-#ifdef UNUSED_CODE
-void debug_enable _PARAMS((int, int));
-void debug_disable _PARAMS((int));
-void debug_reset _PARAMS((void));
-int debug_ok _PARAMS((int, int));
-#endif /* UNUSED_CODE */
-
-#define HOST_CACHE_TTL 3600
-
-typedef struct _host {
-    char key[SQUIDHOSTNAMELEN];        /* www.bar.com */
-    char fqdn[SQUIDHOSTNAMELEN];       /* real.bar.com */
-    char dotaddr[16];          /* 128.138.213.10 */
-    char ipaddr[4];
-    time_t last_t;             /* last access of this info */
-    int n;                     /* # of requests for this host */
-    int addrlen;               /* length of 'ipaddr', always 4 */
-    struct _host *next;
-} Host;
-
-extern Host *thisHost;
-
-Host *get_host _PARAMS((char *hostname));
-int delete_host _PARAMS((Host * h));
-int expire_host_cache _PARAMS((time_t timeout));
-#ifdef UNUSED_CODE
-void dump_host_cache _PARAMS((int, int));
-#endif
 
 char *mkhttpdlogtime _PARAMS((time_t *));
 extern char *mkrfc850 _PARAMS((time_t *));
index ec21252eed6b55b1e480310f70873e992d94868c..0e2aefd8f500da6119ded4dcd8e9e139c0388194 100644 (file)
@@ -3,7 +3,7 @@
 #
 #  Darren Hardy, hardy@cs.colorado.edu, April 1994
 #
-#  $Id: Makefile.in,v 1.10 1996/07/16 01:50:15 wessels Exp $
+#  $Id: Makefile.in,v 1.11 1996/08/26 19:57:00 wessels Exp $
 #
 prefix         = @prefix@
 srcdir         = @srcdir@
@@ -23,7 +23,6 @@ INCLUDE               = -I../include -I$(srcdir)/../include
 UTILOBJS       = rfc850.o \
                  rfc1738.o \
                  util.o \
-                 host_cache.o \
                  getfullhostname.o \
                  debug.o \
                  log.o \
index 1adb718a3c348635105e425c0496cf8c162f1d7b..b0d94f0a35ee0a67b2a5082e4cfce0ec8fa4e5e6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: acl.cc,v 1.27 1996/08/19 22:44:48 wessels Exp $
+ * $Id: acl.cc,v 1.28 1996/08/26 19:57:02 wessels Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -58,6 +58,7 @@ static struct _acl_time_data *aclParseTimeSpec _PARAMS((void));
 static wordlist *aclParseWordList _PARAMS((void));
 static wordlist *aclParseDomainList _PARAMS((void));
 static squid_acl aclType _PARAMS((char *s));
+static int decode_addr _PARAMS((char *, struct in_addr *, struct in_addr *));
 
 static squid_acl aclType(s)
      char *s;
@@ -197,6 +198,8 @@ static int decode_addr(asc, addr, mask)
            mask->s_addr = htonl(0xFFFFFF00);
        else
            mask->s_addr = htonl(0xFFFFFFFF);
+       addr->s_addr &= mask->s_addr;
+       /* 1.2.3.4/255.255.255.0  --> 1.2.3.0 */
     }
     return 1;
 }
index 25dd308e82fe84be017d49e915c1ccdc54242197..c2e908dbc423ce24488e82718be18eeeb44ef68b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cachemgr.cc,v 1.15 1996/08/21 20:11:54 wessels Exp $
+ * $Id: cachemgr.cc,v 1.16 1996/08/26 19:57:02 wessels Exp $
  *
  * DEBUG: Section 0     CGI Cache Manager
  * AUTHOR: Harvest Derived
@@ -847,7 +847,7 @@ int main(int argc, char *argv[])
                    sscanf(reserve, "%s %d %d %d %d %f %d %d %d",
                        s1, &d1, &d2, &d3, &d4, &f1, &d5, &d6, &d7);
                    if (hasTables)
-                       printf("<tr><td><B>%s</B><td>%d<td>%d<td>%d<td>%d<td>%4.2f<td>%d<td>%d<td>%d",
+                       printf("<tr><td align=right><B>%s</B><td align=right>%d<td align=right>%d<td align=right>%d<td align=right>%d<td align=right>%4.2f<td align=right>%d<td align=right>%d<td align=right>%d",
                            s1, d1, d2, d3, d4, f1, d5, d6, d7);
                    else
                        printf("%8s %7d %10d %10d %9d    %4.2f %10d  %10d   %10d<BR>\n",
index 91f3d2b6a34d02bba72d02d2a9cb01c0041f720d..dc9e445860d14840f7d8f5e083f900a398578701 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.57 1996/08/26 19:09:34 wessels Exp $
+ * $Id: comm.cc,v 1.58 1996/08/26 19:57:03 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -1082,48 +1082,53 @@ static int examine_select(readfds, writefds, exceptfds)
        FD_ZERO(&write_x);
        FD_ZERO(&except_x);
        tv.tv_sec = tv.tv_usec = 0;
-       if ((FD_ISSET(fd, readfds)) ||
-           (FD_ISSET(fd, writefds)) ||
-           (FD_ISSET(fd, exceptfds))) {
+       if (FD_ISSET(fd, readfds))
            FD_SET(fd, &read_x);
-           num = select(FD_SETSIZE, &read_x, &read_x, &read_x, &tv);
-           if (num < 0) {
-               f = &fd_table[fd];
-               debug(5, 0, "WARNING: FD %d has handlers, but it's invalid.\n", fd);
-               debug(5, 0, "FD %d is a %s\n", fd, fdstatTypeStr[fdstatGetType(fd)]);
-               debug(5, 0, "--> %s\n", fd_note(fd, NULL));
-               debug(5, 0, "lifetm:%p tmout:%p read:%p write:%p expt:%p\n",
-                   f->lifetime_handler,
-                   f->timeout_handler,
-                   f->read_handler,
-                   f->write_handler,
-                   f->except_handler);
-               for (ch = f->close_handler; ch; ch = ch->next)
-                   debug(5, 0, " close handler: %p\n", ch->handler);
-               if (f->close_handler) {
-                   for (ch = f->close_handler; ch; ch = next) {
-                       next = ch->next;
-                       ch->handler(fd, ch->data);
-                       safe_free(ch);
-                   }
-               } else if (f->lifetime_handler) {
-                   debug(5, 0, "examine_select: Calling Lifetime Handler\n");
-                   f->lifetime_handler(fd, f->lifetime_data);
-               } else if (f->timeout_handler) {
-                   debug(5, 0, "examine_select: Calling Timeout Handler\n");
-                   f->timeout_handler(fd, f->timeout_data);
-               }
-               f->close_handler = 0;
-               f->lifetime_handler = 0;
-               f->timeout_handler = 0;
-               f->read_handler = 0;
-               f->write_handler = 0;
-               f->except_handler = 0;
-               FD_CLR(fd, readfds);
-               FD_CLR(fd, writefds);
-               FD_CLR(fd, exceptfds);
+       else if (FD_ISSET(fd, writefds))
+           FD_SET(fd, &write_x);
+       else if (FD_ISSET(fd, exceptfds))
+           FD_SET(fd, &except_x);
+       else
+           continue;
+       num = select(FD_SETSIZE, &read_x, &write_x, &except_x, &tv);
+       if (num > -1) {
+           debug(5, 5, "FD %d is valid.\n", fd);
+           continue;
+       }
+       f = &fd_table[fd];
+       debug(5, 0, "WARNING: FD %d has handlers, but it's invalid.\n", fd);
+       debug(5, 0, "FD %d is a %s\n", fd, fdstatTypeStr[fdstatGetType(fd)]);
+       debug(5, 0, "--> %s\n", fd_note(fd, NULL));
+       debug(5, 0, "lifetm:%p tmout:%p read:%p write:%p expt:%p\n",
+           f->lifetime_handler,
+           f->timeout_handler,
+           f->read_handler,
+           f->write_handler,
+           f->except_handler);
+       for (ch = f->close_handler; ch; ch = ch->next)
+           debug(5, 0, " close handler: %p\n", ch->handler);
+       if (f->close_handler) {
+           for (ch = f->close_handler; ch; ch = next) {
+               next = ch->next;
+               ch->handler(fd, ch->data);
+               safe_free(ch);
            }
+       } else if (f->lifetime_handler) {
+           debug(5, 0, "examine_select: Calling Lifetime Handler\n");
+           f->lifetime_handler(fd, f->lifetime_data);
+       } else if (f->timeout_handler) {
+           debug(5, 0, "examine_select: Calling Timeout Handler\n");
+           f->timeout_handler(fd, f->timeout_data);
        }
+       f->close_handler = NULL;
+       f->lifetime_handler = NULL;
+       f->timeout_handler = NULL;
+       f->read_handler = NULL;
+       f->write_handler = NULL;
+       f->except_handler = NULL;
+       FD_CLR(fd, readfds);
+       FD_CLR(fd, writefds);
+       FD_CLR(fd, exceptfds);
     }
     return 0;
 }
index 026b2020491aa0eb78001f394b88fb9b551836fa..f82cffaaa55d37db8bce1c8145f26fe11a15cd5f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dnsserver.cc,v 1.12 1996/08/19 22:44:51 wessels Exp $
+ * $Id: dnsserver.cc,v 1.13 1996/08/26 19:57:04 wessels Exp $
  *
  * DEBUG: section 0     DNS Resolver
  * AUTHOR: Harvest Derived
  *   re-implementations of code complying to this set of standards.  
  */
 
-#include "squid.h"
+
+
+
+#include "config.h"
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if HAVE_GRP_H
+#include <grp.h>
+#endif
+#if HAVE_MALLOC_H && !defined(_SQUID_FREEBSD_) && !defined(_SQUID_NEXT_)
+#include <malloc.h>
+#endif
+#if HAVE_MEMORY_H
+#include <memory.h>
+#endif
+#if HAVE_NETDB_H && !defined(_SQUID_NETDB_H_)  /* protect NEXTSTEP */
+#define _SQUID_NETDB_H_
+#include <netdb.h>
+#endif
+#if HAVE_PWD_H
+#include <pwd.h>
+#endif
+#if HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+#if HAVE_TIME_H
+#include <time.h>
+#endif
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#if HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>      /* needs sys/time.h above it */
+#endif
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#if HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+#if HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+#if HAVE_LIBC_H
+#include <libc.h>
+#endif
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#if HAVE_BSTRING_H
+#include <bstring.h>
+#endif
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
 #if HAVE_ARPA_NAMESER_H
 #include <arpa/nameser.h>
 #endif
 #include <resolv.h>
 #endif
 
+#ifndef INADDR_NONE
+#define INADDR_NONE -1
+#endif
+
+#include "util.h"
+
 extern int h_errno;
 
 int do_debug = 0;
index 37fd6ddf70a733d0edac70c93a4c82929c7745a4..dd6bb60f21bb31f9f266f18a7c511df5125e9660 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.cc,v 1.68 1996/08/26 19:16:06 wessels Exp $
+ * $Id: http.cc,v 1.69 1996/08/26 19:57:05 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -337,6 +337,12 @@ void httpProcessReplyHeader(httpState, buf, size)
                httpMakePublic(entry);
            else if (*reply->expires)
                httpMakePublic(entry);
+           else if (entry->mem_obj->request->protocol != PROTO_HTTP)
+               /* XXX Remove this check after a while.  DW 8/21/96
+                * We won't keep some FTP objects from neighbors running
+                * 1.0.8 or earlier because their ftpget's don't 
+                * add a Date: field */
+               httpMakePublic(entry);
            else
                httpMakePrivate(entry);
            break;
@@ -585,7 +591,8 @@ static void httpSendRequest(fd, httpState)
                memset(ybuf, '\0', SM_PAGE_SIZE);
                sprintf(ybuf, "%s %s %s", t, VIA_PROXY_TEXT, version_string);
                t = ybuf;
-           }
+           } else if (strncasecmp(t, "Connection:", 11) == 0)
+               continue;
            if (len + (int) strlen(t) > buflen - 10)
                continue;
            strcat(buf, t);
index 86e5b3fbd3e248ebb465919fb02b1e84b5c5ccda..a35282482734c86e4b4403f9574b7483157c8378 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ipcache.cc,v 1.42 1996/08/26 19:17:59 wessels Exp $
+ * $Id: ipcache.cc,v 1.43 1996/08/26 19:57:07 wessels Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -143,6 +143,7 @@ typedef struct _line_entry {
 
 static int ipcache_testname _PARAMS((void));
 static int ipcache_compareLastRef _PARAMS((ipcache_entry **, ipcache_entry **));
+static int ipcache_reverseLastRef _PARAMS((ipcache_entry **, ipcache_entry **));
 static int ipcache_dnsHandleRead _PARAMS((int, dnsserver_t *));
 static int ipcache_parsebuffer _PARAMS((char *buf, unsigned int offset, dnsserver_t *));
 static void ipcache_release _PARAMS((ipcache_entry *));
@@ -162,6 +163,8 @@ static void ipcacheAddPending _PARAMS((ipcache_entry *, int fd, IPH, void *));
 static void ipcacheEnqueue _PARAMS((ipcache_entry *));
 static void *ipcacheDequeue _PARAMS((void));
 static void ipcache_dnsDispatch _PARAMS((dnsserver_t *, ipcache_entry *));
+static struct hostent *ipcacheCheckNumeric _PARAMS((char *name));
+static void ipcacheStatPrint _PARAMS((ipcache_entry *, StoreEntry *));
 
 static struct hostent *static_result = NULL;
 static HashID ip_table = 0;
@@ -301,6 +304,16 @@ static int ipcache_compareLastRef(e1, e2)
     return (0);
 }
 
+static int ipcache_reverseLastRef(e1, e2)
+     ipcache_entry **e1, **e2;
+{
+    if ((*e1)->lastref < (*e2)->lastref)
+       return (1);
+    if ((*e1)->lastref > (*e2)->lastref)
+       return (-1);
+    return (0);
+}
+
 static int ipcacheExpiredEntry(i)
      ipcache_entry *i;
 {
@@ -308,7 +321,7 @@ static int ipcacheExpiredEntry(i)
        return 0;
     if (i->status == IP_DISPATCHED)
        return 0;
-    if (i->ttl + i->timestamp > squid_curtime)
+    if (i->expires > squid_curtime)
        return 0;
     return 1;
 }
@@ -323,9 +336,8 @@ int ipcache_purgelru()
     int k;
     ipcache_entry **LRU_list = NULL;
     int LRU_list_count = 0;
-    int LRU_cur_size = meta_data.ipcache_count;
 
-    LRU_list = xcalloc(LRU_cur_size, sizeof(ipcache_entry *));
+    LRU_list = xcalloc(meta_data.ipcache_count, sizeof(ipcache_entry *));
 
     for (i = ipcache_GetFirst(); i; i = ipcache_GetNext()) {
        if (ipcacheExpiredEntry(i)) {
@@ -335,14 +347,8 @@ int ipcache_purgelru()
        }
        local_ip_count++;
 
-       if (LRU_list_count >= LRU_cur_size) {
-           /* have to realloc  */
-           LRU_cur_size += 16;
-           debug(14, 3, "ipcache_purgelru: Have to grow LRU_list to %d. This shouldn't happen.\n",
-               LRU_cur_size);
-           LRU_list = xrealloc((char *) LRU_list,
-               LRU_cur_size * sizeof(ipcache_entry *));
-       }
+       if (LRU_list_count == meta_data.ipcache_count)
+           break;
        if (i->status == IP_PENDING)
            continue;
        if (i->status == IP_DISPATCHED)
@@ -363,9 +369,11 @@ int ipcache_purgelru()
        LRU_list_count,
        sizeof(ipcache_entry *),
        (QS) ipcache_compareLastRef);
-    for (k = 0; LRU_list[k] && (meta_data.ipcache_count > ipcache_low)
-       && k < LRU_list_count;
-       ++k) {
+    for (k = 0; k < LRU_list_count; k++) {
+       if (meta_data.ipcache_count < ipcache_low)
+           break;
+       if (LRU_list[k] == NULL)
+           break;
        ipcache_release(LRU_list[k]);
        removed++;
     }
@@ -390,6 +398,7 @@ static ipcache_entry *ipcache_create()
     /* set default to 4, in case parser fail to get token $h_length from
      * dnsserver. */
     new->entry.h_length = 4;
+    new->expires = squid_curtime + Config.negativeDnsTtl;
     return new;
 
 }
@@ -453,13 +462,11 @@ static void ipcache_add(name, i, hp, cached)
        }
        i->entry.h_length = hp->h_length;
        i->entry.h_name = xstrdup(hp->h_name);
-       i->lastref = i->timestamp = squid_curtime;
        i->status = IP_CACHED;
-       i->ttl = Config.positiveDnsTtl;
+       i->expires = squid_curtime + Config.positiveDnsTtl;
     } else {
-       i->lastref = i->timestamp = squid_curtime;
        i->status = IP_NEGATIVE_CACHED;
-       i->ttl = Config.negativeDnsTtl;
+       i->expires = squid_curtime + Config.negativeDnsTtl;
     }
     ipcache_add_to_hash(i);
 }
@@ -588,8 +595,7 @@ static int ipcache_parsebuffer(buf, offset, dnsData)
            } else {
                line_cur = line_head->next;
                i = dnsData->data;
-               i->lastref = i->timestamp = squid_curtime;
-               i->ttl = Config.negativeDnsTtl;
+               i->expires = squid_curtime + Config.negativeDnsTtl;
                i->status = IP_NEGATIVE_CACHED;
                if (line_cur && !strncmp(line_cur->line, "$message", 8))
                    i->error_message = xstrdup(line_cur->line + 8);
@@ -608,8 +614,7 @@ static int ipcache_parsebuffer(buf, offset, dnsData)
                if (i->status != IP_DISPATCHED) {
                    debug(14, 0, "ipcache_parsebuffer: DNS record already resolved.\n");
                } else {
-                   i->lastref = i->timestamp = squid_curtime;
-                   i->ttl = Config.positiveDnsTtl;
+                   i->expires = squid_curtime + Config.positiveDnsTtl;
                    i->status = IP_CACHED;
 
                    line_cur = line_head->next;
@@ -805,16 +810,15 @@ static void ipcacheAddPending(i, fd, handler, handlerData)
 {
     struct _ip_pending *pending = xcalloc(1, sizeof(struct _ip_pending));
     struct _ip_pending **I = NULL;
-
+    i->lastref = squid_curtime;
     pending->fd = fd;
     pending->handler = handler;
     pending->handlerData = handlerData;
-
     for (I = &(i->pending_head); *I; I = &((*I)->next));
     *I = pending;
 }
 
-int ipcache_nbgethostbyname(name, fd, handler, handlerData)
+void ipcache_nbgethostbyname(name, fd, handler, handlerData)
      char *name;
      int fd;
      IPH handler;
@@ -822,6 +826,7 @@ int ipcache_nbgethostbyname(name, fd, handler, handlerData)
 {
     ipcache_entry *i = NULL;
     dnsserver_t *dnsData = NULL;
+    struct hostent *hp = NULL;
 
     if (!handler)
        fatal_dump("ipcache_nbgethostbyname: NULL handler");
@@ -832,7 +837,11 @@ int ipcache_nbgethostbyname(name, fd, handler, handlerData)
     if (name == NULL || name[0] == '\0') {
        debug(14, 4, "ipcache_nbgethostbyname: Invalid name!\n");
        ipcache_call_pending_badname(fd, handler, handlerData);
-       return 0;
+       return;
+    }
+    if ((hp = ipcacheCheckNumeric(name))) {
+       handler(fd, hp, handlerData);
+       return;
     }
     if ((i = ipcache_get(name))) {
        if (ipcacheExpiredEntry(i)) {
@@ -858,12 +867,12 @@ int ipcache_nbgethostbyname(name, fd, handler, handlerData)
            IpcacheStats.hits++;
        ipcacheAddPending(i, fd, handler, handlerData);
        ipcache_call_pending(i);
-       return 0;
+       return;
     } else if (i->status == IP_PENDING || i->status == IP_DISPATCHED) {
        debug(14, 4, "ipcache_nbgethostbyname: PENDING for '%s'\n", name);
        IpcacheStats.pending_hits++;
        ipcacheAddPending(i, fd, handler, handlerData);
-       return 0;
+       return;
     } else {
        fatal_dump("ipcache_nbgethostbyname: BAD ipcache_entry status");
     }
@@ -874,7 +883,6 @@ int ipcache_nbgethostbyname(name, fd, handler, handlerData)
        ipcache_dnsDispatch(dnsData, i);
     else
        ipcacheEnqueue(i);
-    return 0;
 }
 
 static void ipcache_dnsDispatch(dns, i)
@@ -976,12 +984,17 @@ struct hostent *ipcache_gethostbyname(name, flags)
 {
     ipcache_entry *i = NULL;
     struct hostent *hp = NULL;
-    unsigned int ip;
 
     if (!name)
        fatal_dump("ipcache_gethostbyname: NULL name");
     IpcacheStats.requests++;
     if ((i = ipcache_get(name))) {
+       if (ipcacheExpiredEntry(i)) {
+           ipcache_release(i);
+           i = NULL;
+       }
+    }
+    if (i) {
        if (i->status == IP_PENDING || i->status == IP_DISPATCHED) {
            IpcacheStats.pending_hits++;
            return NULL;
@@ -996,12 +1009,8 @@ struct hostent *ipcache_gethostbyname(name, flags)
        }
     }
     IpcacheStats.misses++;
-    /* check if it's already a IP address in text form. */
-    if ((ip = inet_addr(name)) != INADDR_NONE) {
-       *((u_num32 *) (void *) (*static_result->h_addr_list + 0)) = ip;
-       strncpy(static_result->h_name, name, MAX_HOST_NAME);
-       return static_result;
-    }
+    if ((hp = ipcacheCheckNumeric(name)))
+       return hp;
     if (flags & IP_BLOCKING_LOOKUP) {
        IpcacheStats.ghbn_calls++;
        hp = gethostbyname(name);
@@ -1009,30 +1018,59 @@ struct hostent *ipcache_gethostbyname(name, flags)
            /* good address, cached */
            ipcache_add(name, ipcache_create(), hp, 1);
            i = ipcache_get(name);
+           i->lastref = squid_curtime;
+           i->expires = squid_curtime + Config.positiveDnsTtl;
            return &i->entry;
        }
        /* bad address, negative cached */
-       if (ip_table)
+       if (ip_table) {
            ipcache_add(name, ipcache_create(), hp, 0);
-       return NULL;
+           i = ipcache_get(name);
+           i->lastref = squid_curtime;
+           i->expires = squid_curtime + Config.negativeDnsTtl;
+           return NULL;
+       }
     }
     if (flags & IP_LOOKUP_IF_MISS)
        ipcache_nbgethostbyname(name, -1, dummy_handler, NULL);
     return NULL;
 }
 
+static void ipcacheStatPrint(i, sentry)
+     ipcache_entry *i;
+     StoreEntry *sentry;
+{
+    int k;
+    storeAppendPrintf(sentry, " {%-32.32s  %c %6d %6d %d",
+       i->name,
+       ipcache_status_char[i->status],
+       (int) (squid_curtime - i->lastref),
+       (int) (i->expires - squid_curtime),
+       i->addr_count);
+    for (k = 0; k < (int) i->addr_count; k++) {
+       struct in_addr addr;
+       xmemcpy(&addr, i->entry.h_addr_list[k], i->entry.h_length);
+       storeAppendPrintf(sentry, " %15s", inet_ntoa(addr));
+    }
+    for (k = 0; k < (int) i->alias_count; k++) {
+       storeAppendPrintf(sentry, " %s", i->entry.h_aliases[k]);
+    }
+    if (i->entry.h_name && strncmp(i->name, i->entry.h_name, MAX_LINELEN)) {
+       storeAppendPrintf(sentry, " %s", i->entry.h_name);
+    }
+    storeAppendPrintf(sentry, close_bracket);
+}
 
 /* process objects list */
 void stat_ipcache_get(sentry)
      StoreEntry *sentry;
 {
-    ipcache_entry *i = NULL;
     int k;
-    int ttl;
-
+    int N;
+    ipcache_entry *i = NULL;
+    ipcache_entry **list = NULL;
     if (!ip_table)
        return;
-
     storeAppendPrintf(sentry, "{IP Cache Statistics:\n");
     storeAppendPrintf(sentry, "{IPcache Entries: %d}\n",
        meta_data.ipcache_count);
@@ -1052,30 +1090,25 @@ void stat_ipcache_get(sentry)
        IpcacheStats.avg_svc_time);
     storeAppendPrintf(sentry, "}\n\n");
     storeAppendPrintf(sentry, "{IP Cache Contents:\n\n");
-
+    storeAppendPrintf(sentry, " {%-29.29s %5s %6s %6s %1s}\n",
+       "Hostname",
+       "Flags",
+       "lstref",
+       "TTL",
+       "N");
+    list = xcalloc(meta_data.ipcache_count, sizeof(ipcache_entry *));
+    N = 0;
     for (i = ipcache_GetFirst(); i; i = ipcache_GetNext()) {
-       if (i->status == IP_PENDING || i->status == IP_DISPATCHED)
-           ttl = 0;
-       else
-           ttl = (i->ttl + i->timestamp - squid_curtime);
-       storeAppendPrintf(sentry, " {%-32.32s %c %6d %d",
-           i->name,
-           ipcache_status_char[i->status],
-           ttl,
-           (int) i->addr_count);
-       for (k = 0; k < (int) i->addr_count; k++) {
-           struct in_addr addr;
-           xmemcpy(&addr, *(i->entry.h_addr_list + k), i->entry.h_length);
-           storeAppendPrintf(sentry, " %15s", inet_ntoa(addr));
-       }
-       for (k = 0; k < (int) i->alias_count; k++) {
-           storeAppendPrintf(sentry, " %s", i->entry.h_aliases[k]);
-       }
-       if (i->entry.h_name && strncmp(i->name, i->entry.h_name, MAX_LINELEN)) {
-           storeAppendPrintf(sentry, " %s", i->entry.h_name);
-       }
-       storeAppendPrintf(sentry, close_bracket);
+       *(list + N) = i;
+       if (++N > meta_data.ipcache_count)
+           fatal_dump("stat_ipcache_get: meta_data.ipcache_count mismatch");
     }
+    qsort((char *) list,
+       N,
+       sizeof(ipcache_entry *),
+       (QS) ipcache_reverseLastRef);
+    for (k = 0; k < N; k++)
+       ipcacheStatPrint(*(list + k), sentry);
     storeAppendPrintf(sentry, close_bracket);
 }
 
@@ -1117,7 +1150,19 @@ void ipcacheInvalidate(name)
     if ((i = ipcache_get(name)) == NULL)
        return;
     if (i->status != IP_CACHED)
-       i->ttl = 0;
+       i->expires = squid_curtime;
     else
        ipcache_release(i);
 }
+
+static struct hostent *ipcacheCheckNumeric(name)
+     char *name;
+{
+    unsigned int ip;
+    /* check if it's already a IP address in text form. */
+    if ((ip = inet_addr(name)) == INADDR_NONE)
+       return NULL;
+    *((u_num32 *) (void *) static_result->h_addr_list[0]) = ip;
+    strncpy(static_result->h_name, name, MAX_HOST_NAME);
+    return static_result;
+}
index 6f693ca6b13c4c3a7111a82cd6c615ec4058ebfc..79a08dcce25716312695824930090661dc300242 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: neighbors.cc,v 1.43 1996/08/23 21:29:57 wessels Exp $
+ * $Id: neighbors.cc,v 1.44 1996/08/26 19:57:08 wessels Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -319,7 +319,6 @@ void neighbors_open(fd)
     memset(&name, '\0', sizeof(struct sockaddr_in));
     if (getsockname(fd, (struct sockaddr *) &name, &len) < 0)
        debug(15, 1, "getsockname(%d,%p,%p) failed.\n", fd, &name, &len);
-    friends->fd = fd;
 
     /* Prepare neighbor connections, one at a time */
     E = &friends->edges_head;
@@ -420,7 +419,12 @@ int neighborsUdpPing(proto)
 
     if (friends->edges_head == NULL)
        return 0;
-
+    if (theOutIcpConnection < 0) {
+       debug(15, 0, "neighborsUdpPing: There is no ICP socket!\n");
+       debug(15, 0, "Cannot query neighbors for '%s'.\n", url);
+       debug(15, 0, "Check 'icp_port' in your config file\n");
+       fatal_dump(NULL);
+    }
     for (i = 0, e = friends->first_ping; i++ < friends->n; e = e->next) {
        if (entry->swap_status != NO_SWAP)
            fatal_dump("neighborsUdpPing: bad swap_status");
@@ -455,7 +459,7 @@ int neighborsUdpPing(proto)
        if (e->icp_port == echo_port) {
            debug(15, 4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping\n");
            echo_hdr.reqnum = reqnum;
-           icpUdpSend(friends->fd,
+           icpUdpSend(theOutIcpConnection,
                url,
                &echo_hdr,
                &e->in_addr,
@@ -464,7 +468,7 @@ int neighborsUdpPing(proto)
                LOG_TAG_NONE);
        } else {
            e->header.reqnum = reqnum;
-           icpUdpSend(friends->fd,
+           icpUdpSend(theOutIcpConnection,
                url,
                &e->header,
                &e->in_addr,
@@ -508,7 +512,7 @@ int neighborsUdpPing(proto)
            xmemcpy(&to_addr.sin_addr, hep->h_addr, hep->h_length);
            to_addr.sin_port = htons(echo_port);
            echo_hdr.reqnum = reqnum;
-           icpUdpSend(friends->fd,
+           icpUdpSend(theOutIcpConnection,
                url,
                &echo_hdr,
                &to_addr,
index 9f9dc0b56fbeeff6f24c06603892356aff05bdfb..1742c45f4204129558d17ecdcb7f1c2693380aa2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.38 1996/08/26 19:15:41 wessels Exp $
+ * $Id: squid.h,v 1.39 1996/08/26 19:57:11 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
 #define SA_RESETHAND 0
 #endif
 #if SA_RESETHAND == 0 && defined(SA_ONESHOT)
+#undef SA_RESETHAND
 #define SA_RESETHAND SA_ONESHOT
 #endif
 
index 803ef5f528345a2e849423436cb4cfb692a863ce..86a451abbdd74f781eebeeea06122e572aac1da9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.11 1996/08/26 19:16:08 wessels Exp $
+ * $Id: ssl.cc,v 1.12 1996/08/26 19:57:11 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -88,6 +88,10 @@ static int sslClientClosed(fd, sslState)
     debug(26, 3, "sslClientClosed: FD %d\n", fd);
     /* we have been called from comm_close for the client side, so
      * just need to clean up the server side */
+    protoUnregister(sslState->server.fd,
+       NULL,
+       sslState->request,
+       no_addr);
     comm_close(sslState->server.fd);
     return 0;
 }
index d5e64d6c2faaf4d14cf1550329c70f9dffc87b49..9a81c15a71d49c28ab5a9db45ff1d924fecc0708 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.11 1996/08/26 19:16:08 wessels Exp $
+ * $Id: tunnel.cc,v 1.12 1996/08/26 19:57:11 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -88,6 +88,10 @@ static int sslClientClosed(fd, sslState)
     debug(26, 3, "sslClientClosed: FD %d\n", fd);
     /* we have been called from comm_close for the client side, so
      * just need to clean up the server side */
+    protoUnregister(sslState->server.fd,
+       NULL,
+       sslState->request,
+       no_addr);
     comm_close(sslState->server.fd);
     return 0;
 }