*/
extern void md5Digest(u_char * msg, int length, u_char * key, u_char * digest);
extern int parse_app_community_string(struct snmp_session *session);
-
+
/***********************************************************
Copyright 1989 by Carnegie Mellon University
assert(fastmap != NULL && p != NULL);
INIT_FAIL_STACK();
- memset(fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */
+ memset(fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */
bufp->fastmap_accurate = 1; /* It will be when we're done. */
bufp->can_be_null = 0;
+
+
/* taken from RFC-1321/Appendix A.3 */
/*
/*
- * $Id: rfc1123.c,v 1.13 1998/01/07 22:45:23 wessels Exp $
+ * $Id: rfc1123.c,v 1.14 1998/02/02 21:16:13 wessels Exp $
*
* DEBUG:
* AUTHOR: Harvest Derived
day_offset = 1;
len = strftime(buf, 127 - 5, "%d/%b/%Y:%H:%M:%S ", lt);
- snprintf(buf + len, 128-len, "%+03d%02d",
+ snprintf(buf + len, 128 - len, "%+03d%02d",
(min_offset / 60) % 24,
min_offset % 60);
#else /* USE_GMT */
/*
- * $Id: rfc1738.c,v 1.14 1998/01/05 00:57:54 wessels Exp $
+ * $Id: rfc1738.c,v 1.15 1998/02/02 21:16:13 wessels Exp $
*
* DEBUG:
* AUTHOR: Harvest Derived
}
/* Do the triplet encoding, or just copy the char */
/* note: we do not need snprintf here as q is appropriately
- allocated - KA */
+ * allocated - KA */
if (do_escape == 1) {
(void) sprintf(q, "%%%02x", (unsigned char) *p);
return 0;
if (a4 < 0 || a4 > 255)
return 0;
- snprintf(addrbuf,32, "%d.%d.%d.%d", a1, a2, a3, a4);
+ snprintf(addrbuf, 32, "%d.%d.%d.%d", a1, a2, a3, a4);
A.s_addr = inet_addr(addrbuf);
if (addr)
addr->s_addr = A.s_addr;
/* Stub function for programs not implementing statMemoryAccounted */
#include <config.h>
-int statMemoryAccounted(void)
+int
+statMemoryAccounted(void)
{
- return -1;
+ return -1;
}
/*
- * $Id: util.c,v 1.39 1998/01/06 00:27:53 wessels Exp $
+ * $Id: util.c,v 1.40 1998/02/02 21:16:15 wessels Exp $
*
* DEBUG:
* AUTHOR: Harvest Derived
xmalloc_count(void *p, int sign)
{
int statMemoryAccounted();
- static size_t last_total=0,last_accounted=0,last_mallinfo=0;
- struct mallinfo mp=mallinfo();
- size_t accounted=statMemoryAccounted();
+ static size_t last_total = 0, last_accounted = 0, last_mallinfo = 0;
+ struct mallinfo mp = mallinfo();
+ size_t accounted = statMemoryAccounted();
size_t mi = mp.uordblks + mp.usmblks + mp.hblkhd;
size_t sz;
static size_t total = 0;
(int) total - last_total, (int) total,
(int) accounted - last_accounted, (int) accounted,
(int) mi - last_mallinfo, (int) mi);
- last_total=total;
- last_accounted=accounted;
- last_mallinfo=mi;
+ last_total = total;
+ last_accounted = accounted;
+ last_mallinfo = mi;
}
#endif /* XMALLOC_COUNT */
/*
- * $Id: asn.cc,v 1.15 1998/02/02 21:14:55 wessels Exp $
+ * $Id: asn.cc,v 1.16 1998/02/02 21:16:17 wessels Exp $
*
* DEBUG: section 53 AS Number handling
* AUTHOR: Duane Wessels, Kostas Anagnostakis
memFree(MEM_4K_BUF, buf);
return;
} else if (size < 0) {
- debug(50, 1) ("asHandleReply: Called with size=%d.\n", size);
+ debug(50, 1) ("asHandleReply: Called with size=%d.\n", size);
memFree(MEM_4K_BUF, buf);
return;
}
+
/*
- * $Id: client.cc,v 1.49 1998/01/12 04:30:36 wessels Exp $
+ * $Id: client.cc,v 1.50 1998/02/02 21:16:18 wessels Exp $
*
* DEBUG: section 0 WWW Client
* AUTHOR: Harvest Derived
/*
- * $Id: client_side.cc,v 1.201 1998/02/02 21:14:57 wessels Exp $
+ * $Id: client_side.cc,v 1.202 1998/02/02 21:16:19 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
http->out.offset = 0;
protoDispatch(http->conn->fd, http->entry, http->request);
/* Register with storage manager to receive updates when data comes in. */
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientProcessExpired: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(entry,
http->out.offset,
entry->refcount++;
} else if (mem->reply->code == 0) {
debug(33, 3) ("clientHandleIMSReply: Incomplete headers for '%s'\n", url);
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientHandleIMSReply: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(entry,
http->out.offset + size,
/* use clientCacheHit() here as the callback because we might
* be swapping in from disk, and the file might not really be
* there */
- if(entry->store_status == STORE_ABORTED) {
+ if (entry->store_status == STORE_ABORTED) {
debug(33, 0) ("clientHandleIMSReply: IMS swapin failed on aborted object\n");
http->log_type = LOG_TCP_SWAPFAIL_MISS;
clientProcessMiss(http);
}
void
-clientUpdateCounters(clientHttpRequest *http)
+clientUpdateCounters(clientHttpRequest * http)
{
- Counter.client_http.requests++;
- kb_incr(&Counter.client_http.kbytes_in, http->req_sz);
- kb_incr(&Counter.client_http.kbytes_out, http->out.size);
- if (isTcpHit(http->log_type)) {
- Counter.client_http.hits++;
- kb_incr(&Counter.client_http.hit_kbytes_out, http->out.size);
- }
- if (http->request->err_type != ERR_NONE)
- Counter.client_http.errors++;
+ Counter.client_http.requests++;
+ kb_incr(&Counter.client_http.kbytes_in, http->req_sz);
+ kb_incr(&Counter.client_http.kbytes_out, http->out.size);
+ if (isTcpHit(http->log_type)) {
+ Counter.client_http.hits++;
+ kb_incr(&Counter.client_http.hit_kbytes_out, http->out.size);
+ }
+ if (http->request->err_type != ERR_NONE)
+ Counter.client_http.errors++;
}
static void
debug(12, 3) ("clientSendMoreData: Appending %d bytes after headers\n",
(int) (size - hdrlen));
if (((size - hdrlen) + l) > 8192) {
- debug(0,0) ("Size, hdrlen, l %d, %d, %d\n", size, hdrlen, l);
+ debug(0, 0) ("Size, hdrlen, l %d, %d, %d\n", size, hdrlen, l);
return;
}
xmemcpy(newbuf + l, buf + hdrlen, size - hdrlen);
if ((http = conn->chr) != NULL) {
debug(12, 1) ("clientWriteComplete: FD %d Sending next request\n", fd);
if (!storeClientCopyPending(http->entry, http)) {
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientWriteComplete: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(http->entry,
http->out.offset,
} else {
/* More data will be coming from primary server; register with
* storage manager. */
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientWriteComplete 2: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(entry,
http->out.offset,
return;
}
/* All headers are not yet available, wait for more data */
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientGetHeadersForIMS: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(entry,
http->out.offset + size,
http->log_type = LOG_TCP_IMS_HIT;
entry->refcount++;
if (modifiedSince(entry, http->request)) {
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientGetHeadersForIMS 2: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(entry,
http->out.offset,
case LOG_TCP_NEGATIVE_HIT:
case LOG_TCP_MEM_HIT:
entry->refcount++; /* HIT CASE */
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientProcessRequest: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(entry,
http->out.offset,
http);
break;
case LOG_TCP_IMS_MISS:
- if(entry->store_status == STORE_ABORTED)
+ if (entry->store_status == STORE_ABORTED)
debug(33, 0) ("clientProcessRequest 2: entry->swap_status == STORE_ABORTED\n");
storeClientCopy(entry,
http->out.offset,
/*
- * $Id: comm.cc,v 1.223 1998/02/02 21:14:58 wessels Exp $
+ * $Id: comm.cc,v 1.224 1998/02/02 21:16:20 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
debug(5, 3) ("commConnectDnsHandle: Unknown host: %s\n", cs->host);
if (!dns_error_message) {
dns_error_message = "Unknown DNS error";
- debug(5,1) ("commConnectDnsHandle: Bad dns_error_message\n");
+ debug(5, 1) ("commConnectDnsHandle: Bad dns_error_message\n");
}
assert(dns_error_message != NULL);
commConnectCallback(cs, COMM_ERR_DNS);
F = &fd_table[fd];
if (EBIT_TEST(F->flags, FD_CLOSING))
return;
- if(shutdown_pending && (!F->open || F->type == FD_FILE))
+ if (shutdown_pending && (!F->open || F->type == FD_FILE))
return;
assert(F->open);
assert(F->type != FD_FILE);
if (((revents = pfds[i].revents) == 0) || ((fd = pfds[i].fd) == -1))
continue;
if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR)) {
- if(hdl = fd_table[fd].read_handler) {
+ if (hdl = fd_table[fd].read_handler) {
fd_table[fd].read_handler = NULL;
hdl(fd, fd_table[fd].read_data);
} else
- debug(5,1) ("comm_poll_incoming: NULL read handler\n");
+ debug(5, 1) ("comm_poll_incoming: NULL read handler\n");
}
if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR)) {
- if(hdl = fd_table[fd].write_handler) {
+ if (hdl = fd_table[fd].write_handler) {
fd_table[fd].write_handler = NULL;
hdl(fd, fd_table[fd].write_data);
} else
- debug(5,1) ("comm_poll_incoming: NULL write handler\n");
+ debug(5, 1) ("comm_poll_incoming: NULL write handler\n");
}
}
/* TO FIX: repoll ICP connection here */
for (i = 0; i < N; i++) {
fd = fds[i];
if (FD_ISSET(fd, &read_mask)) {
- if((hdl = fd_table[fd].read_handler) != NULL) {
+ if ((hdl = fd_table[fd].read_handler) != NULL) {
fd_table[fd].read_handler = NULL;
hdl(fd, fd_table[fd].read_data);
} else {
- debug(5,1) ("comm_select_incoming: NULL read handler\n");
+ debug(5, 1) ("comm_select_incoming: NULL read handler\n");
}
}
if (FD_ISSET(fd, &write_mask)) {
- if((hdl = fd_table[fd].write_handler) != NULL) {
+ if ((hdl = fd_table[fd].write_handler) != NULL) {
fd_table[fd].write_handler = NULL;
hdl(fd, fd_table[fd].write_data);
} else {
- debug(5,1) ("comm_select_incoming: NULL write handler\n");
+ debug(5, 1) ("comm_select_incoming: NULL write handler\n");
}
}
}
F->timeout_handler = NULL;
F->read_handler = NULL;
F->write_handler = NULL;
- if(F->open != 0)
+ if (F->open != 0)
fd_close(fd);
}
lastinc = polledinc;
debug(5, 5) ("comm_write: FD %d: sz %d: hndl %p: data %p.\n",
fd, size, handler, handler_data);
if (fd_table[fd].rwstate) {
- debug(5,1) ("comm_write: fd_table[%d].rwstate != NULL", fd);
+ debug(5, 1) ("comm_write: fd_table[%d].rwstate != NULL", fd);
state = fd_table[fd].rwstate;
- debug(5,1) ("comm_write: %d'%s',(%d,%d)'%s'\n", size, buf, state->size,
+ debug(5, 1) ("comm_write: %d'%s',(%d,%d)'%s'\n", size, buf, state->size,
state->offset, state->buf);
safe_free(fd_table[fd].rwstate);
fd_table[fd].rwstate = NULL;
/*
- * $Id: disk.cc,v 1.97 1998/02/02 21:14:59 wessels Exp $
+ * $Id: disk.cc,v 1.98 1998/02/02 21:16:21 wessels Exp $
*
* DEBUG: section 6 Disk I/O Routines
* AUTHOR: Harvest Derived
{
open_ctrl_t *ctrlp = (open_ctrl_t *) data;
- if(fd == -2 && errcode == -2) { /* Cancelled - clean up */
+ if (fd == -2 && errcode == -2) { /* Cancelled - clean up */
if (ctrlp->callback)
(ctrlp->callback) (ctrlp->callback_data, fd, errcode);
xfree(ctrlp->path);
file_close(int fd)
{
fde *F = &fd_table[fd];
- if(fd < 0) {
+ if (fd < 0) {
debug(6, 0) ("file_close: FD less than zero: %d\n", fd);
return;
}
if (q == NULL) /* Someone aborted then write completed */
return;
- if(len == -2 && errcode == -2) { /* Write cancelled - cleanup */
+ if (len == -2 && errcode == -2) { /* Write cancelled - cleanup */
do {
fdd->write_q = q->next;
if (q->free)
} while ((q = fdd->write_q));
return;
}
-
fd_bytes(fd, len, FD_WRITE);
if (len < 0) {
if (!ignoreErrno(errno)) {
xfree(data);
- if(len == -2 && errcode == -2) { /* Read cancelled - cleanup */
+ if (len == -2 && errcode == -2) { /* Read cancelled - cleanup */
cbdataUnlock(ctrl_dat->client_data);
safe_free(ctrl_dat);
return;
}
-
fd_bytes(fd, len, FD_READ);
if (len < 0) {
if (ignoreErrno(errno)) {
/*
- * $Id: dns.cc,v 1.52 1998/01/31 05:31:55 wessels Exp $
+ * $Id: dns.cc,v 1.53 1998/02/02 21:16:22 wessels Exp $
*
* DEBUG: section 34 Dnsserver interface
* AUTHOR: Harvest Derived
for (k = 0; k < N; k++) {
dns_child_table[k] = xcalloc(1, sizeof(dnsserver_t));
cbdataAdd(dns_child_table[k], MEM_NONE);
- x = ipcCreate(IPC_TCP_SOCKET,
- prg,
- args,
- "dnsserver",
- &rfd,
- &wfd);
+ x = ipcCreate(IPC_TCP_SOCKET,
+ prg,
+ args,
+ "dnsserver",
+ &rfd,
+ &wfd);
if (x < 0) {
debug(34, 1) ("dnsOpenServers: WARNING: Failed to start 'dnsserver' #%d.\n", k + 1);
EBIT_CLR(dns_child_table[k]->flags, HELPER_ALIVE);
snprintf(fd_note_buf, FD_DESC_SZ, "%s #%d", s, dns_child_table[k]->id);
fd_note(dns_child_table[k]->inpipe, fd_note_buf);
commSetNonBlocking(dns_child_table[k]->inpipe);
- debug(34, 3) ("dnsOpenServers: 'dns_server' %d started\n", k+1);
+ debug(34, 3) ("dnsOpenServers: 'dns_server' %d started\n", k + 1);
NDnsServersAlloc++;
}
}
/*
- * $Id: dnsserver.cc,v 1.40 1998/01/31 05:31:56 wessels Exp $
+ * $Id: dnsserver.cc,v 1.41 1998/02/02 21:16:23 wessels Exp $
*
* DEBUG: section 0 DNS Resolver
* AUTHOR: Harvest Derived
/* read from ipcache */
if (fgets(request, REQ_SZ, stdin) == NULL) {
-fprintf(stderr, "dnsserver %d got EOF\n", (int) getpid());
+ fprintf(stderr, "dnsserver %d got EOF\n", (int) getpid());
exit(1);
- }
+ }
t = strrchr(request, '\n');
if (t == NULL) /* Ignore if no newline */
continue;
/*
- * $Id: fd.cc,v 1.18 1998/02/02 21:15:01 wessels Exp $
+ * $Id: fd.cc,v 1.19 1998/02/02 21:16:24 wessels Exp $
*
* DEBUG: section 51 Filedescriptor Functions
* AUTHOR: Duane Wessels
assert(fd < Squid_MaxFD);
if (fd > Biggest_FD) {
if (status != FD_OPEN)
- debug(51,1) ("fdUpdateBiggest: status != FD_OPEN\n");
+ debug(51, 1) ("fdUpdateBiggest: status != FD_OPEN\n");
Biggest_FD = fd;
return;
}
/* if we are here, then fd == Biggest_FD */
if (status != FD_CLOSE)
- debug(51,1) ("fdUpdateBiggest: status != FD_CLOSE\n");
+ debug(51, 1) ("fdUpdateBiggest: status != FD_CLOSE\n");
while (fd_table[Biggest_FD].open != FD_OPEN)
Biggest_FD--;
}
{
fde *F = &fd_table[fd];
assert(fd >= 0);
- if(F->open != 0) {
+ if (F->open != 0) {
debug(51, 1) ("WARNING: Closing open FD %4d\n", fd);
fd_close(fd);
}
/*
- * $Id: ftp.cc,v 1.188 1998/02/02 19:50:10 wessels Exp $
+ * $Id: ftp.cc,v 1.189 1998/02/02 21:16:25 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
storeAppendPrintf(e, "</PRE>\n");
if (EBIT_TEST(ftpState->flags, FTP_LISTFORMAT_UNKNOWN) && !EBIT_TEST(ftpState->flags, FTP_TRIED_NLST)) {
storeAppendPrintf(e, "<A HREF=\"./;type=d\">[As plain directory]</A>\n");
- } else if (ftpState->typecode=='D') {
+ } else if (ftpState->typecode == 'D') {
storeAppendPrintf(e, "<A HREF=\"./\">[As extended directory]</A>\n");
}
storeAppendPrintf(e, "<HR>\n");
xbuf = xstrdup(buf);
if (EBIT_TEST(flags, FTP_TRIED_NLST)) {
/* Machine readable format, one name per line */
- p->name=xbuf;
- p->type='\0';
+ p->name = xbuf;
+ p->type = '\0';
return p;
}
for (t = strtok(xbuf, w_space); t && n_tokens < MAX_TOKENS; t = strtok(NULL, w_space))
return html;
}
if ((parts = ftpListParseParts(line, flags)) == NULL) {
- char *p;
+ char *p;
snprintf(html, 8192, "%s\n", line);
- for(p=line;*p && isspace(*p);p++);
+ for (p = line; *p && isspace(*p); p++);
if (*p && !isspace(*p))
EBIT_SET(ftpState->flags, FTP_LISTFORMAT_UNKNOWN);
return html;
/*
- * $Id: ipc.cc,v 1.1 1998/01/31 05:34:57 wessels Exp $
+ * $Id: ipc.cc,v 1.2 1998/02/02 21:16:26 wessels Exp $
*
* DEBUG: section 54 Interprocess Communication
* AUTHOR: Duane Wessels
}
if (type == IPC_TCP_SOCKET) {
if (listen(crfd, 1) < 0) {
- debug(50,1)("ipcCreate: listen FD %d: %s\n", crfd, xstrerror());
+ debug(50, 1) ("ipcCreate: listen FD %d: %s\n", crfd, xstrerror());
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
debug(54, 3) ("ipcCreate: FD %d listening...\n", crfd);
}
-
/* flush or else we get dup data if unbuffered_logs is set */
logsFlush();
if ((pid = fork()) < 0) {
close(crfd);
cwfd = crfd = fd;
} else if (type == IPC_UDP_SOCKET) {
- if (comm_connect_addr(crfd, &PS) == COMM_ERROR)
- return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
+ if (comm_connect_addr(crfd, &PS) == COMM_ERROR)
+ return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
-
if (type == IPC_UDP_SOCKET) {
x = send(cwfd, hello_string, strlen(hello_string), 0);
if (x < 0) {
extern void asnFreeMemory(void);
extern void dlinkAdd(void *data, dlink_node *, dlink_list *);
extern void dlinkDelete(dlink_node * m, dlink_list * list);
-extern void kb_incr (kb_t *, size_t);
+extern void kb_incr(kb_t *, size_t);
/*
* prototypes for system functions missing from system includes
#endif
extern int ipcCreate(int type,
- const char *prog,
- char *const args[],
- const char *name,
- int *rfd,
- int *wfd);
-
-extern int handleConnectionHeader(int, char * , char * );
+ const char *prog,
+ char *const args[],
+ const char *name,
+ int *rfd,
+ int *wfd);
+extern int handleConnectionHeader(int, char *, char *);
+
/*
- * $Id: recv-announce.cc,v 1.15 1997/12/02 00:17:39 wessels Exp $
+ * $Id: recv-announce.cc,v 1.16 1998/02/02 21:16:28 wessels Exp $
*
* DEBUG: section 0 Announcement Server
* AUTHOR: Harvest Derived
/*
- * $Id: redirect.cc,v 1.53 1998/01/31 05:32:04 wessels Exp $
+ * $Id: redirect.cc,v 1.54 1998/02/02 21:16:29 wessels Exp $
*
* DEBUG: section 29 Redirector
* AUTHOR: Duane Wessels
NRedirectors, prg);
for (k = 0; k < NRedirectors; k++) {
redirect_child_table[k] = xcalloc(1, sizeof(redirector_t));
- args[0] = "(redirector)";
- args[1] = NULL;
- x = ipcCreate(IPC_TCP_SOCKET,
- prg,
- args,
- "redirector",
- &redirectsocket,
- &redirectsocket);
+ args[0] = "(redirector)";
+ args[1] = NULL;
+ x = ipcCreate(IPC_TCP_SOCKET,
+ prg,
+ args,
+ "redirector",
+ &redirectsocket,
+ &redirectsocket);
if (x < 0) {
debug(29, 1) ("WARNING: Cannot run '%s' process.\n", prg);
EBIT_CLR(redirect_child_table[k]->flags, HELPER_ALIVE);
/*
- * $Id: squid.h,v 1.152 1998/01/06 00:28:01 wessels Exp $
+ * $Id: squid.h,v 1.153 1998/02/02 21:16:31 wessels Exp $
*
* AUTHOR: Duane Wessels
*
int ru_maxrss;
int ru_majflt;
};
+
#endif
#if !defined(HAVE_GETPAGESIZE) && defined(_SQUID_HPUX_)
/*
- * $Id: stat.cc,v 1.187 1998/02/02 19:50:12 wessels Exp $
+ * $Id: stat.cc,v 1.188 1998/02/02 21:16:32 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
void
stat_utilization_get(StoreEntry * e)
{
- /* MAKE SOMETHING UP */
+ /* MAKE SOMETHING UP */
}
void
storeAppendPrintf(sentry, "cpu_time = %f\n",
f->cputime);
storeAppendPrintf(sentry, "wall_time = %f\n",
- tvSubDsec(f->timestamp, current_time));
+ tvSubDsec(f->timestamp, current_time));
}
#define XAVG(X) (dt ? (double) (f->X - l->X) / dt : 0.0)
assert(N_COUNT_HIST > 1);
assert(minutes > 0);
f = &CountHist[0];
- if (minutes > N_COUNT_HIST-1)
- minutes = N_COUNT_HIST-1;
+ if (minutes > N_COUNT_HIST - 1)
+ minutes = N_COUNT_HIST - 1;
l = &CountHist[minutes];
dt = tvSubDsec(l->timestamp, f->timestamp);
ct = f->cputime - l->cputime;
XAVG(select_loops));
storeAppendPrintf(sentry, "cpu_time = %f seconds\n", ct);
storeAppendPrintf(sentry, "wall_time = %f seconds\n", dt);
- storeAppendPrintf(sentry, "cpu_usage = %f%%\n",dpercent(ct,dt));
+ storeAppendPrintf(sentry, "cpu_usage = %f%%\n", dpercent(ct, dt));
}
void
server_pconn_hist[i] = 0;
}
memset(CountHist, '\0', N_COUNT_HIST * sizeof(StatCounters));
- for (i=0; i<N_COUNT_HIST; i++)
+ for (i = 0; i < N_COUNT_HIST; i++)
CountHist[i].timestamp = current_time;
Counter.timestamp = current_time;
eventAdd("statAvgTick", statAvgTick, NULL, 60);
}
void
-statAvg5min(StoreEntry *e)
+statAvg5min(StoreEntry * e)
{
#if NOT_YET
- statCountersDump(e);
- storeAppendPrintf(e, "\n");
+ statCountersDump(e);
+ storeAppendPrintf(e, "\n");
#endif
- statAvgDump(e, 5);
+ statAvgDump(e, 5);
}
void
-statAvg60min(StoreEntry *e)
+statAvg60min(StoreEntry * e)
{
#if NOT_YET
- statCountersDump(e);
- storeAppendPrintf(e, "\n");
+ statCountersDump(e);
+ storeAppendPrintf(e, "\n");
#endif
- statAvgDump(e, 60);
+ statAvgDump(e, 60);
}
/*
- * $Id: stmem.cc,v 1.56 1998/02/02 21:15:06 wessels Exp $
+ * $Id: stmem.cc,v 1.57 1998/02/02 21:16:33 wessels Exp $
*
* DEBUG: section 19 Memory Primitives
* AUTHOR: Harvest Derived
/* Seek our way into store */
while ((t_off + p->len) < offset) {
t_off += p->len;
- if(!p->next) {
- debug(19,1) ("memCopy: p->next == NULL\n");
+ if (!p->next) {
+ debug(19, 1) ("memCopy: p->next == NULL\n");
return 0;
}
assert(p->next);
/*
- * $Id: store.cc,v 1.369 1998/02/02 21:15:08 wessels Exp $
+ * $Id: store.cc,v 1.370 1998/02/02 21:16:34 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
static AIOCB storeValidateComplete;
static void storeRebuiltFromDisk(struct storeRebuildState *data);
static unsigned int getKeyCounter(void);
-static void storePutUnusedFileno(StoreEntry *e);
+static void storePutUnusedFileno(StoreEntry * e);
static int storeGetUnusedFileno(void);
static void storeCheckSwapOut(StoreEntry * e);
static void storeSwapoutFileOpened(void *data, int fd, int errcode);
}
static void
-destroy_MemObject(StoreEntry *e)
+destroy_MemObject(StoreEntry * e)
{
MemObject *mem = e->mem_obj;
debug(20, 3) ("destroy_MemObject: destroying %p\n", mem);
destroy_MemObjectData(mem);
meta_data.misc -= strlen(mem->log_url);
#if USE_ASYNC_IO
- while(mem->clients != NULL)
+ while (mem->clients != NULL)
storeUnregister(e, mem->clients->callback_data);
#endif
assert(mem->clients == NULL);
MemObject *mem;
xfree(ctrlp);
- if(fd == -2 && errcode == -2) { /* Cancelled - Clean up */
+ if (fd == -2 && errcode == -2) { /* Cancelled - Clean up */
xfree(swapfilename);
return;
}
if (e->swap_file_number > -1) {
#if MONOTONIC_STORE
#if USE_ASYNC_IO
- safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
+ safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
#else
- unlinkdUnlink(storeSwapFullPath(e->swap_file_number, NULL));
+ unlinkdUnlink(storeSwapFullPath(e->swap_file_number, NULL));
#endif
#else
storePutUnusedFileno(e);
return;
}
#if USE_ASYNC_IO
- if(mem == NULL) {
+ if (mem == NULL) {
debug(20, 1) ("storeSwapOutHandle: mem == NULL : Cancelling swapout\n");
return;
}
debug(20, 3) ("storeCheckSwapOut: swapout.done_offset = %d\n",
(int) mem->swapout.done_offset);
#if USE_ASYNC_IO
- if(mem->inmem_hi < mem->swapout.queue_offset) {
+ if (mem->inmem_hi < mem->swapout.queue_offset) {
storeAbort(e, 0);
assert(EBIT_TEST(e->flag, RELEASE_REQUEST));
storeSwapOutFileClose(e);
new_mem_lo = lowest_offset;
if (!EBIT_TEST(e->flag, ENTRY_CACHABLE)) {
- if(!EBIT_TEST(e->flag, KEY_PRIVATE))
+ if (!EBIT_TEST(e->flag, KEY_PRIVATE))
debug(20, 0) ("storeCheckSwapOut: Attempt to swap out a non-cacheable non-private object!\n");
stmemFreeDataUpto(mem->data, new_mem_lo);
mem->inmem_lo = new_mem_lo;
swapin_ctrl_t *ctrlp = (swapin_ctrl_t *) data;
StoreEntry *e;
- if(retcode == -2 && errcode == -2) {
+ if (retcode == -2 && errcode == -2) {
xfree(ctrlp);
return;
}
MemObject *mem = e->mem_obj;
struct stat sb;
- if(fd == -2 && errcode == -2) {
+ if (fd == -2 && errcode == -2) {
xfree(ctrlp->path);
xfree(ctrlp);
return;
}
-
assert(mem != NULL);
assert(e->mem_status == NOT_IN_MEMORY);
assert(e->swap_status == SWAPOUT_WRITING || e->swap_status == SWAPOUT_DONE);
- if (e->swap_status == SWAPOUT_DONE && (fd>=0) && fstat(fd, &sb) == 0)
- if(sb.st_size == 0 || sb.st_size != e->object_len) {
- debug(20,0) ("storeSwapInFileOpened: %s: Size mismatch: %d(fstat) != %d(object)\n", ctrlp->path, sb.st_size, e->object_len);
+ if (e->swap_status == SWAPOUT_DONE && (fd >= 0) && fstat(fd, &sb) == 0)
+ if (sb.st_size == 0 || sb.st_size != e->object_len) {
+ debug(20, 0) ("storeSwapInFileOpened: %s: Size mismatch: %d(fstat) != %d(object)\n", ctrlp->path, sb.st_size, e->object_len);
file_close(fd);
fd = -1;
}
xfree(ctrlp);
return;
}
-
debug(20, 5) ("storeSwapInStart: initialized swap file '%s' for '%s'\n",
ctrlp->path, mem->url);
(ctrlp->callback) (fd, ctrlp->callback_data);
size = (off_t) scan5;
if (size < 0) {
- if((key = storeKeyScan(keytext)) == NULL)
+ if ((key = storeKeyScan(keytext)) == NULL)
continue;
- if((e = storeGet(key)) == NULL)
+ if ((e = storeGet(key)) == NULL)
continue;
- if(e->lastref > lastref)
+ if (e->lastref > lastref)
continue;
debug(20, 3) ("storeRebuildFromDisk: Cancelling: '%s'\n", keytext);
storeRelease(e);
RB->cancelcount++;
continue;
}
-
storeSwapFullPath(sfileno, swapfile);
if (EBIT_TEST(scan7, KEY_PRIVATE)) {
RB->badflags++;
StoreEntry *e = data;
storeUnlockObject(e);
outvalid--;
- if(retcode == -2 && errcode == -2)
+ if (retcode == -2 && errcode == -2)
return;
if (!EBIT_TEST(e->flag, ENTRY_VALIDATED))
storeRelease(e);
StoreEntry *e = ctrlp->e;
char *path;
- if(retcode == -2 && errcode == -2) {
+ if (retcode == -2 && errcode == -2) {
xfree(sb);
xfree(ctrlp);
ctrlp->callback(ctrlp->callback_data, retcode, errcode);
return;
#if USE_ASYNC_IO
/* Need to cancel any pending ASYNC writes right now */
- if(mem->swapout.fd >= 0)
+ if (mem->swapout.fd >= 0)
aioCancel(mem->swapout.fd, NULL);
#endif
/* but dont close if a disk write is queued, the handler will close up */
if (++scanned > max_scan)
break;
}
- if(bigclean)
- level = 1;
+ if (bigclean)
+ level = 1;
debug(20, level) ("storeMaintainSwapSpace stats:\n");
debug(20, level) (" %6d objects\n", memInUse(MEM_STOREENTRY));
debug(20, level) (" %6d were scanned\n", scanned);
return 0;
}
#if USE_ASYNC_IO
- aioCancel(-1, e); /* Make sure all forgotten async ops are cancelled */
+ aioCancel(-1, e); /* Make sure all forgotten async ops are cancelled */
#else
if (store_rebuilding) {
debug(20, 2) ("storeRelease: Delaying release until store is rebuilt: '%s'\n",
assert(callback != NULL);
if (e->store_status == STORE_ABORTED) {
#if USE_ASYNC_IO
- if(sc->disk_op_in_progress == 1) {
- if(sc->swapin_fd >= 0)
+ if (sc->disk_op_in_progress == 1) {
+ if (sc->swapin_fd >= 0)
aioCancel(sc->swapin_fd, NULL);
else
aioCancel(-1, sc);
} else if (e->store_status == STORE_OK && sc->copy_offset == e->object_len) {
/* There is no more to send! */
#if USE_ASYNC_IO
- if(sc->disk_op_in_progress == 1) {
- if(sc->swapin_fd >= 0)
+ if (sc->disk_op_in_progress == 1) {
+ if (sc->swapin_fd >= 0)
aioCancel(sc->swapin_fd, NULL);
else
aioCancel(-1, sc);
debug(20, 3) ("storeClientCopy2: Copying from memory\n");
sz = stmemCopy(mem->data, sc->copy_offset, sc->copy_buf, sc->copy_size);
#if USE_ASYNC_IO
- if(sc->disk_op_in_progress == 1) {
- if(sc->swapin_fd >= 0)
+ if (sc->disk_op_in_progress == 1) {
+ if (sc->swapin_fd >= 0)
aioCancel(sc->swapin_fd, NULL);
else
aioCancel(-1, sc);
assert(sc->type == STORE_DISK_CLIENT);
/* gotta open the swapin file */
/* assert(sc->copy_offset == 0); */
- if(sc->disk_op_in_progress == 0) {
+ if (sc->disk_op_in_progress == 0) {
sc->disk_op_in_progress = 1;
storeSwapInStart(e, storeClientCopyFileOpened, sc);
} else {
debug(20, 3) ("storeClientCopy: reading from disk FD %d\n",
sc->swapin_fd);
assert(sc->type == STORE_DISK_CLIENT);
- if(sc->disk_op_in_progress == 0) {
+ if (sc->disk_op_in_progress == 0) {
sc->disk_op_in_progress = 1;
storeClientCopyFileRead(sc);
} else {
}
static void
-storePutUnusedFileno(StoreEntry *e)
+storePutUnusedFileno(StoreEntry * e)
{
assert(storeDirMapBitTest(e->swap_file_number));
storeDirMapBitReset(e->swap_file_number);
/* event to avoid serving up the wrong data. This will leave us with */
/* a URL pointing to no file at all, but that's okay since it'll fail */
/* and get removed later anyway. */
- if(store_rebuilding) {
- if(EBIT_TEST(e->flag, ENTRY_VALIDATED))
+ if (store_rebuilding) {
+ if (EBIT_TEST(e->flag, ENTRY_VALIDATED))
safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
return;
}
fd = storeGetNextFile(&sfileno, &size);
if (fd == -2) {
debug(20, 1) ("StoreRebuildFromSwapFiles: done!\n");
- store_rebuilding = 0;
- return;
+ store_rebuilding = 0;
+ return;
} else if (fd == 0) {
continue;
}
safeunlink(storeSwapFullPath(sfileno, NULL), 1);
continue;
}
-
-
/* get the standard meta data for the StoreEntry */
memset(&tmpe, '\0', sizeof(StoreEntry));
cur = 0;
return -1;
}
- tmp_buf = &write_buf[cur]; /* position ourselves */
+ tmp_buf = &write_buf[cur]; /* position ourselves */
xmemcpy(len, SwapMetaSize(tmp_buf), sizeof(int)); /* length */
*type = SwapMetaType(tmp_buf); /* type */
+
struct _acl_ip_data {
struct in_addr addr1; /* if addr2 non-zero then its a range */
struct in_addr addr2;
off_t queue_offset;
off_t done_offset;
int fd;
- int meta_len;
- char *meta_buf;
+ int meta_len;
+ char *meta_buf;
} swapout;
struct _http_reply *reply;
request_t *request;
/*
- * $Id: tools.cc,v 1.143 1998/02/02 21:15:10 wessels Exp $
+ * $Id: tools.cc,v 1.144 1998/02/02 21:16:36 wessels Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
list->tail = m->prev;
}
-void kb_incr(kb_t *k, size_t v)
+void
+kb_incr(kb_t * k, size_t v)
{
- k->bytes += v;
- k->kb += (k->bytes >> 10);
- k->bytes &= 0x3FF;
+ k->bytes += v;
+ k->kb += (k->bytes >> 10);
+ k->bytes &= 0x3FF;
}
typedef unsigned int swap_status_t;
typedef struct {
- size_t bytes;
- size_t kb;
+ size_t bytes;
+ size_t kb;
} kb_t;
/*
/*
- * $Id: unlinkd.cc,v 1.15 1998/02/02 21:15:12 wessels Exp $
+ * $Id: unlinkd.cc,v 1.16 1998/02/02 21:16:38 wessels Exp $
*
* DEBUG: section 43 Unlink Daemon
* AUTHOR: Duane Wessels
static int
unlinkdCreate(void)
{
- int x;
- int rfd;
- int wfd;
- char *args[2];
- struct timeval slp;
- args[0] = "(unlinkd)";
- args[1] = NULL;
- x = ipcCreate(IPC_FIFO,
- Config.Program.unlinkd,
- args,
- "unlinkd",
- &rfd,
- &wfd);
- if (x < 0)
- return -1;
- slp.tv_sec = 0;
- slp.tv_usec = 250000;
- select(0, NULL, NULL, NULL, &slp);
- fd_note(wfd, "squid -> unlinkd");
- fd_note(rfd, "unlinkd -> squid");
- commSetTimeout(rfd, -1, NULL, NULL);
- commSetTimeout(wfd, -1, NULL, NULL);
- commSetNonBlocking(wfd);
- return wfd;
+ int x;
+ int rfd;
+ int wfd;
+ char *args[2];
+ struct timeval slp;
+ args[0] = "(unlinkd)";
+ args[1] = NULL;
+ x = ipcCreate(IPC_FIFO,
+ Config.Program.unlinkd,
+ args,
+ "unlinkd",
+ &rfd,
+ &wfd);
+ if (x < 0)
+ return -1;
+ slp.tv_sec = 0;
+ slp.tv_usec = 250000;
+ select(0, NULL, NULL, NULL, &slp);
+ fd_note(wfd, "squid -> unlinkd");
+ fd_note(rfd, "unlinkd -> squid");
+ commSetTimeout(rfd, -1, NULL, NULL);
+ commSetTimeout(wfd, -1, NULL, NULL);
+ commSetNonBlocking(wfd);
+ return wfd;
}
void