]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Removed 'meta_data' structure. Use mem.c routines instead, or
authorwessels <>
Sat, 7 Mar 1998 05:19:30 +0000 (05:19 +0000)
committerwessels <>
Sat, 7 Mar 1998 05:19:30 +0000 (05:19 +0000)
simply stop accounting for some things

19 files changed:
src/client_db.cc
src/client_side.cc
src/comm.cc
src/enums.h
src/filemap.cc
src/fqdncache.cc
src/globals.h
src/htcp.cc
src/ipcache.cc
src/main.cc
src/mem.cc
src/net_db.cc
src/protos.h
src/snmp_agent.cc
src/stat.cc
src/store.cc
src/store_key_md5.cc
src/structs.h
src/typedefs.h

index 65887ac0e33e9a584d8c23acb9aae7072be69e83..50fbb2f3622bfd56fda69c276f85aab849d4389c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_db.cc,v 1.22 1998/03/06 21:05:48 wessels Exp $
+ * $Id: client_db.cc,v 1.23 1998/03/06 22:19:30 wessels Exp $
  *
  * DEBUG: section 0     Client Database
  * AUTHOR: Duane Wessels
 
 #include "squid.h"
 
-typedef struct _client_info {
-    char *key;
-    struct client_info *next;
-    struct in_addr addr;
-    struct {
-       int result_hist[LOG_TYPE_MAX];
-       int n_requests;
-    } Http, Icp;
-    struct {
-       time_t time;
-       int n_req;
-       int n_denied;
-    } cutoff;
-} ClientInfo;
-
 static hash_table *client_table = NULL;
 static ClientInfo *clientdbAdd(struct in_addr addr);
 
@@ -53,11 +38,10 @@ static ClientInfo *
 clientdbAdd(struct in_addr addr)
 {
     ClientInfo *c;
-    c = xcalloc(1, sizeof(ClientInfo));
+    c = memAllocate(MEM_CLIENT_INFO);
     c->key = xstrdup(inet_ntoa(addr));
     c->addr = addr;
     hash_join(client_table, (hash_link *) c);
-    meta_data.client_info++;
     return c;
 }
 
@@ -67,7 +51,6 @@ clientdbInit(void)
     if (client_table)
        return;
     client_table = hash_create((HASHCMP *) strcmp, 229, hash_string);
-    client_info_sz = sizeof(ClientInfo);
     cachemgrRegister("client_list",
        "Cache Client List",
        clientdbDump,
@@ -105,7 +88,7 @@ clientdbCutoffDenied(struct in_addr addr)
     int ND;
     double p;
     ClientInfo *c;
-    if (!Config.Options.client_db)
+    if (!Config.onoff.client_db)
        return 0;
     key = inet_ntoa(addr);
     c = (ClientInfo *) hash_lookup(client_table, key);
@@ -127,9 +110,9 @@ clientdbCutoffDenied(struct in_addr addr)
     p = 100.0 * ND / NR;
     if (p < 95.0)
        return 0;
-    debug(1, 0"WARNING: Probable misconfigured neighbor at %s\n", key);
-    debug(1, 0"WARNING: %d of the last %d ICP replies are DENIED\n", ND, NR);
-    debug(1, 0"WARNING: No replies will be sent for the next %d seconds\n",
+    debug(1, 0) ("WARNING: Probable misconfigured neighbor at %s\n", key);
+    debug(1, 0) ("WARNING: %d of the last %d ICP replies are DENIED\n", ND, NR);
+    debug(1, 0) ("WARNING: No replies will be sent for the next %d seconds\n",
        CUTOFF_SECONDS);
     c->cutoff.time = squid_curtime;
     c->cutoff.n_req = c->Icp.n_requests;
index 2c3cdb5606ac5500c4309c07c57a0e993e37afcb..15e7fde39dd52d969f27aa81e872f834a8945e02 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.221 1998/03/06 05:43:34 kostas Exp $
+ * $Id: client_side.cc,v 1.222 1998/03/06 22:19:31 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -614,7 +614,7 @@ connStateFree(int fd, void *data)
     if (connState->ident.fd > -1)
        comm_close(connState->ident.fd);
     safe_free(connState->in.buf);
-    meta_data.misc -= connState->in.size;
+    /* XXX account connState->in.buf */
     pconnHistCount(0, connState->nrequests);
     cbdataFree(connState);
 }
@@ -1743,7 +1743,7 @@ clientReadRequest(int fd, void *data)
                /* Grow the request memory area to accomodate for a large request */
                conn->in.size += REQUEST_BUF_SIZE;
                conn->in.buf = xrealloc(conn->in.buf, conn->in.size);
-               meta_data.misc += REQUEST_BUF_SIZE;
+               /* XXX account conn->in.buf */
                debug(33, 2) ("Handling a large request, offset=%d inbufsize=%d\n",
                    conn->in.offset, conn->in.size);
                k = conn->in.size - 1 - conn->in.offset;
@@ -1824,7 +1824,7 @@ httpAccept(int sock, void *notused)
     connState->in.size = REQUEST_BUF_SIZE;
     connState->in.buf = xcalloc(connState->in.size, 1);
     cbdataAdd(connState, MEM_NONE);
-    meta_data.misc += connState->in.size;
+    /* XXX account connState->in.buf */
     comm_add_close_handler(fd, connStateFree, connState);
     if (Config.onoff.log_fqdn)
        fqdncache_gethostbyaddr(peer.sin_addr, FQDN_LOOKUP_IF_MISS);
index bdb9a372408c1a1501046abac02b3d83ca54cf28..b34979265042b9037a4319f53654f625e881f07f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.231 1998/02/25 20:13:47 wessels Exp $
+ * $Id: comm.cc,v 1.232 1998/03/06 22:19:32 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -1251,13 +1251,11 @@ int
 comm_init(void)
 {
     fd_table = xcalloc(Squid_MaxFD, sizeof(fde));
-    meta_data.misc += Squid_MaxFD * sizeof(fde);
+    /* XXX account fd_table */
     /* Keep a few file descriptors free so that we don't run out of FD's
      * after accepting a client but before it opens a socket or a file.
      * Since Squid_MaxFD can be as high as several thousand, don't waste them */
     RESERVED_FD = XMIN(100, Squid_MaxFD / 4);
-    /* hardwired lifetimes */
-    meta_data.misc += Squid_MaxFD * sizeof(int);
     zero_tv.tv_sec = 0;
     zero_tv.tv_usec = 0;
     return 0;
index d481cef60a45ae2b64f31762ad3b8257b9ee3af7..a945233889a277797bc2066a9adda21e0f7528ee 100644 (file)
@@ -47,8 +47,8 @@ typedef enum {
     ERR_CACHE_MGR_ACCESS_DENIED,
     ERR_SQUID_SIGNATURE,       /* not really an error */
     ERR_FTP_PUT_CREATED,       /* !error,a note that the file was created */
-    ERR_FTP_PUT_MODIFIED,      /* modified, !created*/
-    ERR_FTP_PUT_ERROR, 
+    ERR_FTP_PUT_MODIFIED,      /* modified, !created */
+    ERR_FTP_PUT_ERROR,
     ERR_MAX
 } err_type;
 
@@ -470,6 +470,7 @@ typedef enum {
     MEM_DWRITE_Q,
     MEM_FILEMAP,
     MEM_FQDNCACHE_ENTRY,
+    MEM_FQDNCACHE_PENDING,
     MEM_HASH_LINK,
     MEM_HASH_TABLE,
 #if 0                          /* renamed to detect all old uses */
@@ -484,7 +485,7 @@ typedef enum {
     MEM_ICPUDPDATA,
     MEM_CLIENTHTTPREQUEST,
     MEM_CONNSTATEDATA,
-    MEM_IPCACHE_ADDRS,
+    MEM_IPCACHE_PENDING,
     MEM_IPCACHE_ENTRY,
     MEM_DOMAIN_PING,
     MEM_DOMAIN_TYPE,
@@ -515,6 +516,7 @@ typedef enum {
     MEM_DLINK_NODE,
     MEM_DLINK_LIST,
     MEM_STATCOUNTERS,
+    MEM_CLIENT_INFO,
     MEM_MAX
 } mem_type;
 
index 87c571f2827134702756fb5660d9d398b3739d74..9ecd15bb8bf3761ec9026ca7a7858a1314b0ab3e 100644 (file)
@@ -1,5 +1,6 @@
+
 /*
- * $Id: filemap.cc,v 1.23 1998/02/10 22:29:51 wessels Exp $
+ * $Id: filemap.cc,v 1.24 1998/03/06 22:19:33 wessels Exp $
  *
  * DEBUG: section 8     Swap File Bitmap
  * AUTHOR: Harvest Derived
@@ -133,7 +134,7 @@ file_map_create(int n)
     debug(8, 5) ("--> %d words of %d bytes each\n",
        fm->nwords, sizeof(unsigned long));
     fm->file_map = xcalloc(fm->nwords, sizeof(unsigned long));
-    meta_data.misc += fm->nwords * sizeof(unsigned long);
+    /* XXX account fm->file_map */
     return fm;
 }
 
index 31a8ce94d5d1615bc821cd99acc274f15cfdbab6..e3a8604e0176b752fac01d82e0c1e364ecd53d6f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.90 1998/03/05 00:42:51 wessels Exp $
+ * $Id: fqdncache.cc,v 1.91 1998/03/06 22:19:35 wessels Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
 #define FQDN_LOW_WATER       90
 #define FQDN_HIGH_WATER      95
 
-struct _fqdn_pending {
-    FQDNH *handler;
-    void *handlerData;
-    struct _fqdn_pending *next;
-};
-
 struct fqdncacheQueueData {
     struct fqdncacheQueueData *next;
     fqdncache_entry *f;
@@ -138,7 +132,6 @@ static dlink_list lru_list;
 
 static void fqdncache_dnsHandleRead(int, void *);
 static fqdncache_entry *fqdncache_parsebuffer(const char *buf, dnsserver_t *);
-static void fqdncache_purgelru(void);
 static void fqdncache_release(fqdncache_entry *);
 static fqdncache_entry *fqdncache_create(const char *name);
 static void fqdncache_call_pending(fqdncache_entry *);
@@ -219,8 +212,7 @@ fqdncache_release(fqdncache_entry * f)
     dlinkDelete(&f->lru, &lru_list);
     safe_free(f->name);
     safe_free(f->error_message);
-    safe_free(f);
-    --meta_data.fqdncache_count;
+    memFree(MEM_FQDNCACHE_ENTRY, f);
 }
 
 /* return match for given name */
@@ -252,15 +244,16 @@ fqdncacheExpiredEntry(const fqdncache_entry * f)
     return 1;
 }
 
-static void
-fqdncache_purgelru(void)
+void
+fqdncache_purgelru(void *notused)
 {
     dlink_node *m;
     dlink_node *prev = NULL;
     fqdncache_entry *f;
     int removed = 0;
+    eventAdd("fqdncache_purgelru", fqdncache_purgelru, NULL, 10);
     for (m = lru_list.tail; m; m = prev) {
-       if (meta_data.fqdncache_count < fqdncache_low)
+       if (memInUse(MEM_FQDNCACHE_ENTRY) < fqdncache_low)
            break;
        prev = m->prev;
        f = m->data;
@@ -282,10 +275,7 @@ static fqdncache_entry *
 fqdncache_create(const char *name)
 {
     static fqdncache_entry *f;
-    if (meta_data.fqdncache_count > fqdncache_high)
-       fqdncache_purgelru();
-    meta_data.fqdncache_count++;
-    f = xcalloc(1, sizeof(fqdncache_entry));
+    f = memAllocate(MEM_FQDNCACHE_ENTRY);
     f->name = xstrdup(name);
     f->expires = squid_curtime + Config.negativeDnsTtl;
     hash_join(fqdn_table, (hash_link *) f);
@@ -326,7 +316,7 @@ fqdncacheAddNew(const char *name, const struct hostent *hp, fqdncache_status_t s
 static void
 fqdncache_call_pending(fqdncache_entry * f)
 {
-    struct _fqdn_pending *p = NULL;
+    fqdn_pending *p = NULL;
     int nhandler = 0;
 
     f->lastref = squid_curtime;
@@ -341,7 +331,7 @@ fqdncache_call_pending(fqdncache_entry * f)
            p->handler((f->status == FQDN_CACHED) ? f->names[0] : NULL,
                p->handlerData);
        }
-       safe_free(p);
+       memFree(MEM_FQDNCACHE_PENDING, p);
     }
     f->pending_head = NULL;    /* nuke list */
     debug(35, 10) ("fqdncache_call_pending: Called %d handlers.\n", nhandler);
@@ -505,8 +495,8 @@ fqdncache_dnsHandleRead(int fd, void *data)
 static void
 fqdncacheAddPending(fqdncache_entry * f, FQDNH * handler, void *handlerData)
 {
-    struct _fqdn_pending *pending = xcalloc(1, sizeof(struct _fqdn_pending));
-    struct _fqdn_pending **I = NULL;
+    fqdn_pending *pending = memAllocate(MEM_FQDNCACHE_PENDING);
+    fqdn_pending **I = NULL;
     f->lastref = squid_curtime;
     pending->handler = handler;
     pending->handlerData = handlerData;
@@ -648,7 +638,7 @@ fqdncacheUnregister(struct in_addr addr, void *data)
 {
     char *name = inet_ntoa(addr);
     fqdncache_entry *f = NULL;
-    struct _fqdn_pending *p = NULL;
+    fqdn_pending *p = NULL;
     int n = 0;
     debug(35, 3) ("fqdncacheUnregister: FD %d, name '%s'\n", name);
     if ((f = fqdncache_get(name)) == NULL)
@@ -716,7 +706,7 @@ fqdnStats(StoreEntry * sentry)
        return;
     storeAppendPrintf(sentry, "FQDN Cache Statistics:\n");
     storeAppendPrintf(sentry, "FQDNcache Entries: %d\n",
-       meta_data.fqdncache_count);
+       memInUse(MEM_FQDNCACHE_ENTRY));
     storeAppendPrintf(sentry, "FQDNcache Requests: %d\n",
        FqdncacheStats.requests);
     storeAppendPrintf(sentry, "FQDNcache Hits: %d\n",
@@ -758,7 +748,7 @@ dummy_handler(const char *bufnotused, void *datanotused)
 static int
 fqdncacheHasPending(const fqdncache_entry * f)
 {
-    const struct _fqdn_pending *p = NULL;
+    const fqdn_pending *p = NULL;
     if (f->status != FQDN_PENDING)
        return 0;
     for (p = f->pending_head; p; p = p->next)
@@ -818,9 +808,10 @@ fqdncacheFreeMemory(void)
     int i = 0;
     int j = 0;
     int k = 0;
-    list = xcalloc(meta_data.fqdncache_count, sizeof(fqdncache_entry *));
+    int n = memInUse(MEM_FQDNCACHE_ENTRY);
+    list = xcalloc(n, sizeof(fqdncache_entry *));
     f = (fqdncache_entry *) hash_first(fqdn_table);
-    while (f && i < meta_data.fqdncache_count) {
+    while (f != NULL && i < n) {
        *(list + i) = f;
        i++;
        f = (fqdncache_entry *) hash_next(fqdn_table);
@@ -831,7 +822,7 @@ fqdncacheFreeMemory(void)
            safe_free(f->names[k]);
        safe_free(f->name);
        safe_free(f->error_message);
-       safe_free(f);
+       memFree(MEM_FQDNCACHE_ENTRY, f);
     }
     xfree(list);
     hashFreeMemory(fqdn_table);
index 2900dc48a94acef1174d6ee397f8fe43f2931cb5..7ca7a70c4e097c7b4c7a0511767b37998837bf6a 100644 (file)
@@ -1,11 +1,10 @@
 
 /*
- * $Id: globals.h,v 1.40 1998/02/26 18:00:43 wessels Exp $
+ * $Id: globals.h,v 1.41 1998/03/06 22:19:35 wessels Exp $
  */
 
 extern FILE *debug_log;                /* NULL */
 extern FILE *cache_useragent_log;      /* NULL */
-extern Meta_data meta_data;
 extern SquidConfig Config;
 extern SquidConfig2 Config2;
 extern char *ConfigFile;       /* NULL */
@@ -86,7 +85,6 @@ extern volatile int reconfigure_pending;      /* 0 */
 extern volatile int shutdown_pending;  /* 0 */
 extern int store_rebuilding;   /* 1 */
 extern int store_swap_size;    /* 0 */
-extern int client_info_sz;     /* 0 */
 extern unsigned long store_mem_size;   /* 0 */
 extern icpUdpData *UdpQueueHead;       /* NULL */
 extern icpUdpData *UdpQueueTail;       /* NULL */
@@ -100,6 +98,7 @@ extern double request_failure_ratio; /* 0.0 */
 extern int store_hash_buckets; /* 0 */
 extern hash_table *store_table;        /* NULL */
 extern dlink_list store_list;
+extern int hot_obj_count;      /* 0 */
 
 #ifdef HAVE_SYSLOG
 extern int _db_level;
index 6aaa3b92c514eb5a9fd6440706b8556efe50aa54..379f8c38a1d165e8ffce3e371db96302ac36396a 100644 (file)
@@ -4,83 +4,98 @@ typedef struct _Countstr Countstr;
 typedef struct _htcpHeader htcpHeader;
 typedef struct _htcpDataHeader htcpDataHeader;
 typedef struct _htcpAuthHeader htcpAuthHeader;
+typedef struct _Specifier Specifier;
+typedef struct _Detail Detail;
+typedef struct _Identity Identity;
 
 struct _Countstr {
-       u_short length;
-       char *text;
+    u_short length;
+    char *text;
 };
 
 struct _htcpHeader {
-       u_short length;
-       u_char major;
-       u_char minor;
+    u_short length;
+    u_char major;
+    u_char minor;
 };
 
 struct _htcpDataHeader {
-       u_short length; 
-       u_char opcode:4;
-       u_char response:4;
-       u_char reserved:6;
-       u_char F1:1;
-               /* RR == 0 --> F1 = RESPONSE DESIRED FLAG */
-               /* RR == 1 --> F1 = MESSAGE OVERALL FLAG */
-       u_char RR:1;
-               /* RR == 0 --> REQUEST */
-               /* RR == 1 --> RESPONSE */
-       u_num32 msg_id;
+    u_short length;
+    u_char opcode:4;
+    u_char response:4;
+    u_char reserved:6;
+    u_char F1:1;
+    /* RR == 0 --> F1 = RESPONSE DESIRED FLAG */
+    /* RR == 1 --> F1 = MESSAGE OVERALL FLAG */
+    u_char RR:1;
+    /* RR == 0 --> REQUEST */
+    /* RR == 1 --> RESPONSE */
+    u_num32 msg_id;
 };
 
 struct _htcpAuthHeader {
-       u_short length;
-       time_t sig_time;
-       time_t sig_expire;
-       Countstr key_name;
-       Countstr signature;
+    u_short length;
+    time_t sig_time;
+    time_t sig_expire;
+    Countstr key_name;
+    Countstr signature;
 };
 
 struct _Specifier {
-       Countstr method;
-       Countstr URI;
-       Countstr version;
-       Countstr req_hdrs;
+    Countstr method;
+    Countstr URI;
+    Countstr version;
+    Countstr req_hdrs;
 };
 
 struct _Detail {
-       Countstr resp_hdrs;
-       Countstr entity_hdrs;
-       Countstr cache_hdrs;
+    Countstr resp_hdrs;
+    Countstr entity_hdrs;
+    Countstr cache_hdrs;
 };
 
 struct _Identity {
-       Specifier specifier;
-       Detail detail;
+    Specifier specifier;
+    Detail detail;
 };
 
 enum {
-       HTCP_NOP,
-       HTCP_TST,
-       HTCP_MON,
-       HTCP_SET,
-       HTCP_CLR
+    HTCP_NOP,
+    HTCP_TST,
+    HTCP_MON,
+    HTCP_SET,
+    HTCP_CLR
 };
 
 /*
  * values for htcpDataHeader->response
  */
 enum {
-       AUTH_REQUIRED,
-       AUTH_FAILURE,
-       OPCODE_UNIMPLEMENTED,
-       MAJOR_VERSION_UNSUPPORTED,
-       MINOR_VERSION_UNSUPPORTED,
-       INVALID_OPCODE
+    AUTH_REQUIRED,
+    AUTH_FAILURE,
+    OPCODE_UNIMPLEMENTED,
+    MAJOR_VERSION_UNSUPPORTED,
+    MINOR_VERSION_UNSUPPORTED,
+    INVALID_OPCODE
 };
 
 /*
  * values for htcpDataHeader->RR
  */
 enum {
-       RR_REQUEST,
-       RR_RESPONSE
+    RR_REQUEST,
+    RR_RESPONSE
 };
 
+
+char *
+htpcBuildAuth(u_short * len)
+{
+    static char buf[2];
+    u_short n_len;
+    assert(2 == sizeof(u_short));
+    *len = (u_short) 2;
+    n_len = htons(*len);
+    xmemcpy(buf, &n_len, 2);
+    return buf;
+}
index bc9b55a987eb0bbc8e7648acb4b8f3497c287b0a..87c963ba78635c4deab7dea669b442ed93ec8b05 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.166 1998/03/06 21:05:50 wessels Exp $
+ * $Id: ipcache.cc,v 1.167 1998/03/06 22:19:37 wessels Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
 
 #include "squid.h"
 
-struct _ip_pending {
-    IPH *handler;
-    void *handlerData;
-    struct _ip_pending *next;
-};
-
 struct ipcacheQueueData {
     struct ipcacheQueueData *next;
     ipcache_entry *i;
@@ -259,8 +253,7 @@ ipcache_release(ipcache_entry * i)
     }
     safe_free(i->name);
     safe_free(i->error_message);
-    safe_free(i);
-    --meta_data.ipcache_count;
+    memFree(MEM_IPCACHE_ENTRY, i);
     return;
 }
 
@@ -294,8 +287,9 @@ ipcache_purgelru(void *voidnotused)
     dlink_node *prev = NULL;
     ipcache_entry *i;
     int removed = 0;
+    eventAdd("ipcache_purgelru", ipcache_purgelru, NULL, 10);
     for (m = lru_list.tail; m; m = prev) {
-       if (meta_data.ipcache_count < ipcache_low)
+       if (memInUse(MEM_IPCACHE_ENTRY) < ipcache_low)
            break;
        prev = m->prev;
        i = m->data;
@@ -316,8 +310,7 @@ static ipcache_entry *
 ipcache_create(const char *name)
 {
     static ipcache_entry *i;
-    meta_data.ipcache_count++;
-    i = xcalloc(1, sizeof(ipcache_entry));
+    i = memAllocate(MEM_IPCACHE_ENTRY);
     i->name = xstrdup(name);
     i->expires = squid_curtime + Config.negativeDnsTtl;
     hash_join(ip_table, (hash_link *) i);
@@ -365,7 +358,7 @@ ipcacheAddNew(const char *name, const struct hostent *hp, ipcache_status_t statu
 static void
 ipcache_call_pending(ipcache_entry * i)
 {
-    struct _ip_pending *p = NULL;
+    ip_pending *p = NULL;
     int nhandler = 0;
     i->lastref = squid_curtime;
     ipcacheLockEntry(i);
@@ -381,7 +374,7 @@ ipcache_call_pending(ipcache_entry * i)
            }
            cbdataUnlock(p->handlerData);
        }
-       safe_free(p);
+       memFree(MEM_IPCACHE_PENDING, p);
     }
     i->pending_head = NULL;    /* nuke list */
     debug(14, 10) ("ipcache_call_pending: Called %d handlers.\n", nhandler);
@@ -551,8 +544,8 @@ ipcache_dnsHandleRead(int fd, void *data)
 static void
 ipcacheAddPending(ipcache_entry * i, IPH * handler, void *handlerData)
 {
-    struct _ip_pending *pending = xcalloc(1, sizeof(struct _ip_pending));
-    struct _ip_pending **I = NULL;
+    ip_pending *pending = memAllocate(MEM_IPCACHE_PENDING);
+    ip_pending **I = NULL;
     i->lastref = squid_curtime;
     pending->handler = handler;
     pending->handlerData = handlerData;
@@ -706,7 +699,7 @@ int
 ipcacheUnregister(const char *name, void *data)
 {
     ipcache_entry *i = NULL;
-    struct _ip_pending *p = NULL;
+    ip_pending *p = NULL;
     int n = 0;
     debug(14, 3) ("ipcacheUnregister: name '%s'\n", name);
     if ((i = ipcache_get(name)) == NULL)
@@ -785,7 +778,7 @@ stat_ipcache_get(StoreEntry * sentry)
     assert(ip_table != NULL);
     storeAppendPrintf(sentry, "IP Cache Statistics:\n");
     storeAppendPrintf(sentry, "IPcache Entries: %d\n",
-       meta_data.ipcache_count);
+       memInUse(MEM_IPCACHE_ENTRY));
     storeAppendPrintf(sentry, "IPcache Requests: %d\n",
        IpcacheStats.requests);
     storeAppendPrintf(sentry, "IPcache Hits: %d\n",
@@ -822,7 +815,7 @@ dummy_handler(const ipcache_addrs * addrsnotused, void *datanotused)
 static int
 ipcacheHasPending(ipcache_entry * i)
 {
-    struct _ip_pending *p = NULL;
+    ip_pending *p = NULL;
     if (i->status != IP_PENDING)
        return 0;
     for (p = i->pending_head; p; p = p->next)
@@ -982,9 +975,10 @@ ipcacheFreeMemory(void)
     ipcache_entry **list;
     int k = 0;
     int j;
-    list = xcalloc(meta_data.ipcache_count, sizeof(ipcache_entry *));
+    int n = memInUse(MEM_IPCACHE_ENTRY);
+    list = xcalloc(n, sizeof(ipcache_entry *));
     i = (ipcache_entry *) hash_first(ip_table);
-    while (i && k < meta_data.ipcache_count) {
+    while (i != NULL && k < n) {
        *(list + k) = i;
        k++;
        i = (ipcache_entry *) hash_next(ip_table);
@@ -995,7 +989,7 @@ ipcacheFreeMemory(void)
        safe_free(i->addrs.bad_mask);
        safe_free(i->name);
        safe_free(i->error_message);
-       safe_free(i);
+       memFree(MEM_IPCACHE_ENTRY, i);
     }
     xfree(list);
     hashFreeMemory(ip_table);
index 5fa959536dec62f6202aa7cd4f4397b7020d174c..6ac7535830d1d8144375fe35cf170ef8aede8cda 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.232 1998/03/05 00:42:58 wessels Exp $
+ * $Id: main.cc,v 1.233 1998/03/06 22:19:38 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -502,6 +502,7 @@ mainInitialize(void)
        if (Config.onoff.announce)
            eventAdd("start_announce", start_announce, NULL, 3600);
        eventAdd("ipcache_purgelru", ipcache_purgelru, NULL, 10);
+       eventAdd("fqdncache_purgelru", fqdncache_purgelru, NULL, 15);
     }
     configured_once = 1;
 #ifdef SQUID_SNMP
index ce57b47e2f11d958d5d0e667f7754dc0bce584f0..866a145e021c0496275227d8cb4fc5b6c0e93e7a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mem.cc,v 1.12 1998/03/06 01:30:58 rousskov Exp $
+ * $Id: mem.cc,v 1.13 1998/03/06 22:19:38 wessels Exp $
  *
  * DEBUG: section 13    High Level Memory Pool Management
  * AUTHOR: Harvest Derived
@@ -134,13 +134,12 @@ memInit(void)
     memDataInit(MEM_ICP_PING_DATA, "icp_ping_data", sizeof(icp_ping_data), 0);
     memDataInit(MEM_INTLIST, "intlist", sizeof(intlist), 0);
     memDataInit(MEM_IOSTATS, "iostats", sizeof(iostats), 0);
-    memDataInit(MEM_IPCACHE_ADDRS, "ipcache_addrs", sizeof(ipcache_addrs), 0);
+    memDataInit(MEM_IPCACHE_PENDING, "ip_pending", sizeof(ip_pending), 0);
     memDataInit(MEM_IPCACHE_ENTRY, "ipcache_entry", sizeof(ipcache_entry), 0);
     memDataInit(MEM_MEMOBJECT, "MemObject", sizeof(MemObject),
        Squid_MaxFD >> 3);
     memDataInit(MEM_MEM_HDR, "mem_hdr", sizeof(mem_hdr), 0);
     memDataInit(MEM_MEM_NODE, "mem_node", sizeof(mem_node), 0);
-    memDataInit(MEM_META_DATA, "mem_data", sizeof(meta_data), 0);
     memDataInit(MEM_NETDBENTRY, "netdbEntry", sizeof(netdbEntry), 0);
     memDataInit(MEM_NET_DB_NAME, "net_db_name", sizeof(net_db_name), 0);
     memDataInit(MEM_NET_DB_PEER, "net_db_peer", sizeof(net_db_peer), 0);
@@ -167,6 +166,7 @@ memInit(void)
     memDataInit(MEM_SWAPDIR, "SwapDir", sizeof(SwapDir), 0);
     memDataInit(MEM_USHORTLIST, "ushort_list", sizeof(ushortlist), 0);
     memDataInit(MEM_WORDLIST, "wordlist", sizeof(wordlist), 0);
+    memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0);
     /* test that all entries are initialized */
     for (t = MEM_NONE + 1; t < MEM_MAX; t++) {
        /*
index 603691cf808126f049ef28e56a51af8e4c1c710b..6daae09aac57ffe50366147e4f01bd5990346bda 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.73 1998/03/03 17:10:57 wessels Exp $
+ * $Id: net_db.cc,v 1.74 1998/03/06 22:19:39 wessels Exp $
  *
  * DEBUG: section 37    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -130,7 +130,6 @@ netdbRelease(netdbEntry * n)
     }
     n->hosts = NULL;
     safe_free(n->peers);
-    meta_data.netdb_peers -= n->n_peers_alloc;
     n->peers = NULL;
     n->n_peers = 0;
     n->n_peers_alloc = 0;
@@ -321,12 +320,10 @@ netdbPeerAdd(netdbEntry * n, peer * e)
        debug(37, 3) ("netdbPeerAdd: Growing peer list for '%s' to %d\n",
            n->network, n->n_peers_alloc);
        n->peers = xcalloc(n->n_peers_alloc, sizeof(net_db_peer));
-       meta_data.netdb_peers += n->n_peers_alloc;
        for (i = 0; i < osize; i++)
            *(n->peers + i) = *(o + i);
        if (osize) {
            safe_free(o);
-           meta_data.netdb_peers -= osize;
        }
     }
     p = n->peers + n->n_peers;
index bc9178ea17c4b098974d4c2c6da7c0e1093abf9a..299a25c13ba3b5969fed3fe606fee7667cf95d96 100644 (file)
@@ -185,6 +185,7 @@ extern const char *fqdnFromAddr(struct in_addr);
 extern int fqdncacheQueueDrain(void);
 extern void fqdncacheFreeMemory(void);
 extern void fqdncache_restart(void);
+extern EVH fqdncache_purgelru;
 
 extern void ftpStart(request_t * req, StoreEntry * entry);
 extern char *ftpUrlWith2f(const request_t *);
@@ -271,8 +272,8 @@ extern void httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, double
 /* Http Range Header Field */
 extern HttpHdrRange *httpHdrRangeParseCreate(const char *range_spec);
 /* returns true if ranges are valid; inits HttpHdrRange */
-extern int httpHdrRangeParseInit(HttpHdrRange *range, const char *range_spec);
-extern void httpHdrRangeDestroy(HttpHdrRange *range);
+extern int httpHdrRangeParseInit(HttpHdrRange * range, const char *range_spec);
+extern void httpHdrRangeDestroy(HttpHdrRange * range);
 
 
 
@@ -283,7 +284,7 @@ extern int httpHeaderCalcMask(const int *enums, int count);
 extern int strListGetItem(const char *str, char del, const char **item, int *ilen, const char **pos);
 extern const char *getStringPrefix(const char *str);
 extern int httpHeaderParseInt(const char *start, int *val);
-extern int httpHeaderParseSize(const char *start, size_t *sz);
+extern int httpHeaderParseSize(const char *start, size_t * sz);
 
 /* Http Header */
 extern void httpHeaderInitModule();
@@ -523,7 +524,6 @@ extern void identStart(int, ConnStateData *, IDCB * callback);
 
 extern void statInit(void);
 extern void pconnHistCount(int, int);
-extern int statMemoryAccounted(void);
 
 void statHistClean(StatHist * H);
 void statHistCount(StatHist * H, double val);
@@ -564,6 +564,7 @@ extern int memPoolUsedCount(const MemPool * pool);
 extern void memPoolDescribe(const MemPool * pool);
 extern void memPoolReport(const MemPool * pool, StoreEntry * e);
 extern void memReport(StoreEntry * e);
+extern size_t memTotalAllocated(void);
 
 extern int stmemFreeDataUpto(mem_hdr *, int);
 extern void stmemAppend(mem_hdr *, const char *, int);
@@ -771,8 +772,8 @@ extern void releaseServerSockets(void);
 extern void PrintRusage(void);
 extern void dumpMallocStats(void);
 
-extern void pumpInit(int fd, request_t *r, char *uri);
-extern void pumpStart(int fd, StoreEntry *reply_entry, request_t *r, void *callback, void *cbdata);
+extern void pumpInit(int fd, request_t * r, char *uri);
+extern void pumpStart(int fd, StoreEntry * reply_entry, request_t * r, void *callback, void *cbdata);
 
 extern void unlinkdInit(void);
 extern void unlinkdClose(void);
index f28e549b8581311b34e7657d262ea1cf2d8a8c9e..c7a80f9bce9611baa997848959347498dfbbfa14 100644 (file)
@@ -683,7 +683,7 @@ snmp_prfSysFn(variable_list * Var, long *ErrP)
        *(Answer->val.integer) = IOStats.Http.reads_deferred;
        break;
     case PERF_SYS_MEMUSAGE:
-       *(Answer->val.integer) = (long) statMemoryAccounted() >> 10;
+       *(Answer->val.integer) = (long) memTotalAllocated() >> 10;
        break;
     case PERF_SYS_CPUUSAGE:
        squid_getrusage(&rusage);
index 1818fc076c62fb709f8710193dd7b8534b261d55..0142476dd3ac381711cd3d49134c4fe46ecb709b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.214 1998/03/05 00:43:06 wessels Exp $
+ * $Id: stat.cc,v 1.215 1998/03/06 22:19:41 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -420,19 +420,6 @@ statFiledescriptors(StoreEntry * sentry)
     }
 }
 
-int
-statMemoryAccounted(void)
-{
-    return (int)
-       meta_data.store_keys +
-       meta_data.ipcache_count * sizeof(ipcache_entry) +
-       meta_data.fqdncache_count * sizeof(fqdncache_entry) +
-       hash_links_allocated * sizeof(hash_link) +
-       meta_data.netdb_peers * sizeof(struct _net_db_peer) +
-                 meta_data.client_info * client_info_sz +
-                 meta_data.misc;
-}
-
 void
 info_get(StoreEntry * sentry)
 {
@@ -560,49 +547,7 @@ info_get(StoreEntry * sentry)
     storeAppendPrintf(sentry, "\t%6d StoreEntries with MemObject Data\n",
        memInUse(MEM_MEM_HDR));
     storeAppendPrintf(sentry, "\t%6d Hot Object Cache Items\n",
-       meta_data.hot_vm);
-
-    storeAppendPrintf(sentry, "\t%-25.25s                      = %6d KB\n",
-       "StoreEntry Keys",
-       meta_data.store_keys >> 10);
-
-    storeAppendPrintf(sentry, "\t%-25.25s %7d x %4d bytes = %6d KB\n",
-       "IPCacheEntry",
-       meta_data.ipcache_count,
-       (int) sizeof(ipcache_entry),
-       (int) (meta_data.ipcache_count * sizeof(ipcache_entry) >> 10));
-
-    storeAppendPrintf(sentry, "\t%-25.25s %7d x %4d bytes = %6d KB\n",
-       "FQDNCacheEntry",
-       meta_data.fqdncache_count,
-       (int) sizeof(fqdncache_entry),
-       (int) (meta_data.fqdncache_count * sizeof(fqdncache_entry) >> 10));
-
-    storeAppendPrintf(sentry, "\t%-25.25s %7d x %4d bytes = %6d KB\n",
-       "Hash link",
-       hash_links_allocated,
-       (int) sizeof(hash_link),
-       (int) (hash_links_allocated * sizeof(hash_link) >> 10));
-
-    storeAppendPrintf(sentry, "\t%-25.25s %7d x %4d bytes = %6d KB\n",
-       "NetDB Peer Entries",
-       meta_data.netdb_peers,
-       (int) sizeof(struct _net_db_peer),
-                    (int) (meta_data.netdb_peers * sizeof(struct _net_db_peer) >> 10));
-
-    storeAppendPrintf(sentry, "\t%-25.25s %7d x %4d bytes = %6d KB\n",
-       "ClientDB Entries",
-       meta_data.client_info,
-       client_info_sz,
-       (int) (meta_data.client_info * client_info_sz >> 10));
-
-    storeAppendPrintf(sentry, "\t%-25.25s                      = %6d KB\n",
-       "Miscellaneous",
-       meta_data.misc >> 10);
-
-    storeAppendPrintf(sentry, "\t%-25.25s                      = %6d KB\n",
-       "Total Accounted",
-       statMemoryAccounted() >> 10);
+       hot_obj_count);
 
 #if XMALLOC_STATISTICS
     storeAppendPrintf(sentry, "Memory allocation statistics\n");
index 6588aebe7a6610ead6d4556f0f28dd917d8ea37d..4c8673af3a9a1b866918f01222f5ffe9c2c82575 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.390 1998/03/03 22:56:45 wessels Exp $
+ * $Id: store.cc,v 1.391 1998/03/06 22:19:42 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -180,7 +180,7 @@ new_MemObject(const char *url, const char *log_url)
     mem->log_url = xstrdup(log_url);
     mem->swapout.fd = -1;
     mem->object_sz = -1;
-    meta_data.misc += strlen(log_url);
+    /* XXX account log_url */
     debug(20, 3) ("new_MemObject: returning %p\n", mem);
     return mem;
 }
@@ -204,7 +204,7 @@ destroy_MemObject(StoreEntry * e)
     debug(20, 3) ("destroy_MemObject: destroying %p\n", mem);
     assert(mem->swapout.fd == -1);
     destroy_MemObjectData(mem);
-    meta_data.misc -= strlen(mem->log_url);
+    /* XXX account log_url */
 #if USE_ASYNC_IO
     while (mem->clients != NULL)
        storeUnregister(e, mem->clients->callback_data);
@@ -618,7 +618,7 @@ storeGetMemSpace(int size)
            break;
     }
     debug(20, 3) ("storeGetMemSpace stats:\n");
-    debug(20, 3) ("  %6d HOT objects\n", meta_data.hot_vm);
+    debug(20, 3) ("  %6d HOT objects\n", hot_obj_count);
     debug(20, 3) ("  %6d were released\n", released);
 }
 
@@ -1067,10 +1067,10 @@ storeSetMemStatus(StoreEntry * e, int new_status)
     if (new_status == IN_MEMORY) {
        assert(mem->inmem_lo == 0);
        dlinkAdd(e, &mem->lru, &inmem_list);
-       meta_data.hot_vm++;
+       hot_obj_count++;
     } else {
        dlinkDelete(&mem->lru, &inmem_list);
-       meta_data.hot_vm--;
+       hot_obj_count--;
     }
     e->mem_status = new_status;
 }
index 0a4062d41f0b6a806b1ce180b71b4794b0753cf4..50d4a1ebae82749296615ecb357aa1f53553fb9f 100644 (file)
@@ -98,7 +98,7 @@ storeKeyDup(const cache_key * key)
 {
     cache_key *dup = xmalloc(MD5_DIGEST_CHARS);
     xmemcpy(dup, key, MD5_DIGEST_CHARS);
-    meta_data.store_keys += MD5_DIGEST_CHARS;
+    /* XXX account key */
     return dup;
 }
 
@@ -106,7 +106,7 @@ void
 storeKeyFree(const cache_key * key)
 {
     xfree((void *) key);
-    meta_data.store_keys -= MD5_DIGEST_CHARS;
+    /* XXX account key */
 }
 
 int
index f19b938d3327da877e4a0bb424b873bd0bcd481e..0061241c1d3df77c68bceeb59a275519bf3c3ac8 100644 (file)
@@ -479,9 +479,9 @@ struct _HttpHdrRangeSpec {
 };
 
 /* There may be more than one byte range specified in the request.
  This object holds all range specs in order of their appearence
  in the request because we SHOULD preserve that order.
-*/
* This object holds all range specs in order of their appearence
* in the request because we SHOULD preserve that order.
+ */
 struct _HttpHdrRange {
     Stack specs;
 };
@@ -677,6 +677,12 @@ struct _ipcache_addrs {
     unsigned char badcount;
 };
 
+struct _ip_pending {
+    IPH *handler;
+    void *handlerData;
+    ip_pending *next;
+};
+
 struct _ipcache_entry {
     /* first two items must be equivalent to hash_link in hash.h */
     char *name;
@@ -684,13 +690,19 @@ struct _ipcache_entry {
     time_t lastref;
     time_t expires;
     ipcache_addrs addrs;
-    struct _ip_pending *pending_head;
+    ip_pending *pending_head;
     char *error_message;
     dlink_node lru;
     u_char locks;
     ipcache_status_t status:3;
 };
 
+struct _fqdn_pending {
+    FQDNH *handler;
+    void *handlerData;
+    fqdn_pending *next;
+};
+
 struct _fqdncache_entry {
     /* first two items must be equivalent to hash_link in hash.h */
     char *name;
@@ -699,7 +711,7 @@ struct _fqdncache_entry {
     time_t expires;
     unsigned char name_count;
     char *names[FQDN_MAX_NAMES + 1];
-    struct _fqdn_pending *pending_head;
+    fqdn_pending *pending_head;
     char *error_message;
     dlink_node lru;
     unsigned char locks;
@@ -842,16 +854,6 @@ struct _Stack {
 
 #endif
 
-struct _Meta_data {
-    int hot_vm;
-    int ipcache_count;
-    int fqdncache_count;
-    int netdb_peers;
-    int misc;
-    int client_info;
-    int store_keys;
-};
-
 struct _iostats {
     struct {
        int reads;
@@ -1126,3 +1128,18 @@ struct _storeSwapLogData {
     u_short flags;
     unsigned char key[MD5_DIGEST_CHARS];
 };
+
+struct _ClientInfo {
+    char *key;
+    struct client_info *next;
+    struct in_addr addr;
+    struct {
+       int result_hist[LOG_TYPE_MAX];
+       int n_requests;
+    } Http, Icp;
+    struct {
+       time_t time;
+       int n_req;
+       int n_denied;
+    } cutoff;
+};
index befb8ec8b890060687aa0eb559d076e40ed9a00d..39aa5aa7a2ade7c8b46c72ec1d0a9487b7234f26 100644 (file)
@@ -46,6 +46,7 @@ typedef struct _dwrite_q dwrite_q;
 typedef struct _fde fde;
 typedef struct _fileMap fileMap;
 typedef struct _fqdncache_entry fqdncache_entry;
+typedef struct _fqdn_pending fqdn_pending;
 typedef struct _hash_link hash_link;
 typedef struct _hash_table hash_table;
 typedef struct _HttpReply http_reply;
@@ -67,6 +68,7 @@ typedef struct _clientHttpRequest clientHttpRequest;
 typedef struct _ConnStateData ConnStateData;
 typedef struct _ipcache_addrs ipcache_addrs;
 typedef struct _ipcache_entry ipcache_entry;
+typedef struct _ip_pending ip_pending;
 typedef struct _domain_ping domain_ping;
 typedef struct _domain_type domain_type;
 typedef struct _DynPool DynPool;
@@ -104,6 +106,7 @@ typedef struct _tlv tlv;
 typedef struct _storeSwapLogData storeSwapLogData;
 typedef struct _cacheSwap cacheSwap;
 typedef struct _StatHist StatHist;
+typedef struct _ClientInfo ClientInfo;
 
 /* define AIOCB even without USE_ASYNC_IO */
 typedef void AIOCB(void *, int aio_return, int aio_errno);