/*
- * $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);
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;
}
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,
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);
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;
/*
- * $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
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);
}
/* 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;
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);
/*
- * $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
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;
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;
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 */
MEM_ICPUDPDATA,
MEM_CLIENTHTTPREQUEST,
MEM_CONNSTATEDATA,
- MEM_IPCACHE_ADDRS,
+ MEM_IPCACHE_PENDING,
MEM_IPCACHE_ENTRY,
MEM_DOMAIN_PING,
MEM_DOMAIN_TYPE,
MEM_DLINK_NODE,
MEM_DLINK_LIST,
MEM_STATCOUNTERS,
+ MEM_CLIENT_INFO,
MEM_MAX
} mem_type;
+
/*
- * $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
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;
}
/*
- * $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;
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 *);
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 */
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;
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);
static void
fqdncache_call_pending(fqdncache_entry * f)
{
- struct _fqdn_pending *p = NULL;
+ fqdn_pending *p = NULL;
int nhandler = 0;
f->lastref = squid_curtime;
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);
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;
{
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)
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",
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)
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);
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);
/*
- * $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 */
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 */
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;
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;
+}
/*
- * $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;
}
safe_free(i->name);
safe_free(i->error_message);
- safe_free(i);
- --meta_data.ipcache_count;
+ memFree(MEM_IPCACHE_ENTRY, i);
return;
}
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;
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);
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);
}
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);
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;
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)
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",
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)
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);
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);
/*
- * $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
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
/*
- * $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
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);
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++) {
/*
/*
- * $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
}
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;
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;
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 *);
/* 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);
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();
extern void statInit(void);
extern void pconnHistCount(int, int);
-extern int statMemoryAccounted(void);
void statHistClean(StatHist * H);
void statHistCount(StatHist * H, double val);
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);
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);
*(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);
/*
- * $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
}
}
-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)
{
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");
/*
- * $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
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;
}
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);
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);
}
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;
}
{
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;
}
storeKeyFree(const cache_key * key)
{
xfree((void *) key);
- meta_data.store_keys -= MD5_DIGEST_CHARS;
+ /* XXX account key */
}
int
};
/* 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;
};
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;
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;
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;
#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;
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;
+};
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;
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;
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);