/*
- * $Id: cache_cf.cc,v 1.182 1997/04/30 03:11:58 wessels Exp $
+ * $Id: cache_cf.cc,v 1.183 1997/04/30 18:30:42 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
#define DefaultNegativeTtl (5 * 60) /* 5 min */
#define DefaultNegativeDnsTtl (2 * 60) /* 2 min */
#define DefaultPositiveDnsTtl (360 * 60) /* 6 hours */
-#define DefaultReadTimeout (15 * 60) /* 15 min */
-#define DefaultConnectTimeout 120 /* 2 min */
-#define DefaultDeferTimeout 3600 /* 1 hour */
-#define DefaultClientLifetime 86400 /* 1 day */
-#define DefaultShutdownLifetime 30 /* 30 seconds */
-#define DefaultCleanRate -1 /* disabled */
+#define DefaultReadTimeout (15 * 60) /* 15 min */
+#define DefaultConnectTimeout 120 /* 2 min */
+#define DefaultDeferTimeout 3600 /* 1 hour */
+#define DefaultClientLifetime 86400 /* 1 day */
+#define DefaultShutdownLifetime 30 /* 30 seconds */
+#define DefaultCleanRate -1 /* disabled */
#define DefaultDnsChildren 5 /* 5 processes */
#define DefaultOptionsResDefnames 0 /* default off */
#define DefaultOptionsAnonymizer 0 /* default off */
parseMinutesLine(&Config.negativeDnsTtl);
else if (!strcmp(token, "positive_dns_ttl"))
parseMinutesLine(&Config.positiveDnsTtl);
- else if (!strcmp(token, "read_timeout"))
- parseMinutesLine(&Config.Timeout.read);
- else if (!strcmp(token, "connect_timeout"))
- parseIntegerValue(&Config.Timeout.connect);
- else if (!strcmp(token, "defer_timeout"))
- parseIntegerValue(&Config.Timeout.defer);
- else if (!strcmp(token, "client_lifetime"))
- parseIntegerValue(&Config.Timeout.lifetime);
- else if (!strcmp(token, "shutdown_lifetime"))
- parseIntegerValue(&Config.shutdownLifetime);
+ else if (!strcmp(token, "read_timeout"))
+ parseMinutesLine(&Config.Timeout.read);
+ else if (!strcmp(token, "connect_timeout"))
+ parseIntegerValue(&Config.Timeout.connect);
+ else if (!strcmp(token, "defer_timeout"))
+ parseIntegerValue(&Config.Timeout.defer);
+ else if (!strcmp(token, "client_lifetime"))
+ parseIntegerValue(&Config.Timeout.lifetime);
+ else if (!strcmp(token, "shutdown_lifetime"))
+ parseIntegerValue(&Config.shutdownLifetime);
else if (!strcmp(token, "clean_rate"))
parseMinutesLine(&Config.cleanRate);
else if (!strcmp(token, "reference_age"))
/*
- * $Id: client_side.cc,v 1.98 1997/04/29 22:12:49 wessels Exp $
+ * $Id: client_side.cc,v 1.99 1997/04/30 18:30:44 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
comm_write(fd,
msg,
strlen(msg),
- 30,
icpSendERRORComplete,
icpState,
NULL);
/*
- * $Id: comm.cc,v 1.145 1997/04/30 03:12:00 wessels Exp $
+ * $Id: comm.cc,v 1.146 1997/04/30 18:30:44 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
#define min(x,y) ((x)<(y)? (x) : (y))
#define max(a,b) ((a)>(b)? (a) : (b))
-struct _RWStateData {
+typedef struct _RWStateData {
char *buf;
long size;
long offset;
- int timeout; /* XXX Not used at present. */
- time_t time; /* XXX Not used at present. */
- rw_complete_handler *handler;
+ RWCB *handler;
void *handler_data;
void (*free) (void *);
-};
+} RWStateData;
/* GLOBAL */
FD_ENTRY *fd_table = NULL; /* also used in disk.c */
RWStateCallbackAndFree(int fd, int code)
{
RWStateData *RWState = fd_table[fd].rwstate;
- rw_complete_handler *callback = NULL;
+ RWCB *callback = NULL;
fd_table[fd].rwstate = NULL;
if (RWState == NULL)
return;
}
void
-commConnectStart(int fd, const char *host, u_short port, CCH callback, void *data)
+commConnectStart(int fd, const char *host, u_short port, CNCB * callback, void *data)
{
ConnectStateData *cs = xcalloc(1, sizeof(ConnectStateData));
cs->host = xstrdup(host);
}
}
int
-commSetTimeout(int fd, int timeout, PF *handler, void *data)
+commSetTimeout(int fd, int timeout, PF * handler, void *data)
{
FD_ENTRY *fde;
debug(5, 3, "commSetTimeout: FD %d timeout %d\n", fd, timeout);
if (fd < 0 || fd > Squid_MaxFD)
- fatal_dump("commSetTimeout: bad FD");
+ fatal_dump("commSetTimeout: bad FD");
fde = &fd_table[fd];
if (timeout < 0) {
- fde->timeout_handler = NULL;
- fde->timeout_data = NULL;
- return fde->timeout = 0;
+ fde->timeout_handler = NULL;
+ fde->timeout_data = NULL;
+ return fde->timeout = 0;
}
if (shutdown_pending || reread_pending) {
- /* don't increase the timeout if something pending */
- if (fde->timeout > 0 && (int) (fde->timeout - squid_curtime) < timeout)
- return fde->timeout;
+ /* don't increase the timeout if something pending */
+ if (fde->timeout > 0 && (int) (fde->timeout - squid_curtime) < timeout)
+ return fde->timeout;
}
if (handler || data) {
- fde->timeout_handler = handler;
- fde->timeout_data = data;
+ fde->timeout_handler = handler;
+ fde->timeout_data = data;
} else if (fde->timeout_handler == NULL) {
- debug_trap("commSetTimeout: setting timeout, but no handler");
+ debug_trap("commSetTimeout: setting timeout, but no handler");
}
return fde->timeout = squid_curtime + (time_t) timeout;
}
FD_ENTRY *fde = NULL;
debug(5, 5, "comm_close: FD %d\n", fd);
if (fd < 0)
- fatal_dump("comm_close: bad FD");
+ fatal_dump("comm_close: bad FD");
if (fd >= Squid_MaxFD)
- fatal_dump("comm_close: bad FD");
+ fatal_dump("comm_close: bad FD");
fde = &fd_table[fd];
if (!fde->open)
return;
{
FD_ENTRY *fde;
if (fd < 0)
- fatal_dump("commSetSelect: bad FD");
+ fatal_dump("commSetSelect: bad FD");
fde = &fd_table[fd];
if (type & COMM_SELECT_READ) {
- fde->read_handler = handler;
- fde->read_data = client_data;
+ fde->read_handler = handler;
+ fde->read_data = client_data;
}
if (type & COMM_SELECT_WRITE) {
- fde->write_handler = handler;
- fde->write_data = client_data;
+ fde->write_handler = handler;
+ fde->write_data = client_data;
}
if (timeout)
- fde->timeout = squid_curtime + timeout;
+ fde->timeout = squid_curtime + timeout;
}
void
debug(50, 0, "FD %d: fcntl F_GETFL: %s\n", fd, xstrerror());
return COMM_ERROR;
}
-#if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) && !defined(_SQUID_SOLARIS_)
- if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
- debug(50, 0, "FD %d: error setting O_NONBLOCK: %s\n", fd, xstrerror());
+ if (fcntl(fd, F_SETFL, flags | SQUID_NONBLOCK) < 0) {
+ debug(50, 0, "commSetNonBlocking: FD %d: %s\n", fd, xstrerror());
return COMM_ERROR;
}
-#else
- if (fcntl(fd, F_SETFL, flags | O_NDELAY) < 0) {
- debug(50, 0, "FD %d: error setting O_NDELAY: %s\n", fd, xstrerror());
- return COMM_ERROR;
- }
-#endif
return 0;
}
FD_ENTRY *fde = NULL;
PF *callback;
for (fd = 0; fd <= Biggest_FD; fd++) {
- debug(5, 5, "checkTimeouts: Checking FD %d\n", fd);
fde = &fd_table[fd];
if (fde->open != FD_OPEN)
continue;
/* Select for Writing on FD, until SIZE bytes are sent. Call
* * HANDLER when complete. */
void
-comm_write(int fd, char *buf, int size, int timeout, rw_complete_handler * handler, void *handler_data, void (*free_func) (void *))
+comm_write(int fd, char *buf, int size, RWCB * handler, void *handler_data, void (*free_func) (void *))
{
RWStateData *state = NULL;
state->size = size;
state->offset = 0;
state->handler = handler;
- state->timeout = timeout;
- state->time = squid_curtime;
state->handler_data = handler_data;
state->free = free_func;
fd_table[fd].rwstate = state;
/*
- * $Id: disk.cc,v 1.63 1997/04/30 03:44:41 wessels Exp $
+ * $Id: disk.cc,v 1.64 1997/04/30 18:30:46 wessels Exp $
*
* DEBUG: section 6 Disk I/O Routines
* AUTHOR: Harvest Derived
if (mode & O_WRONLY)
mode |= O_APPEND;
-#if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) && !defined(_SQUID_SOLARIS_)
- mode |= O_NONBLOCK;
-#else
- mode |= O_NDELAY;
-#endif
+ mode |= SQUID_NONBLOCK;
/* Open file */
#if USE_ASYNC_IO
commSetCloseOnExec(fd);
fd_open(fd, FD_FILE, ctrlp->path);
fde = &fd_table[fd];
- xstrncpy(fde->disk.filename, ctrlp->path, SQUID_MAXPATHLEN);
if (ctrlp->callback)
(ctrlp->callback) (ctrlp->callback_data, fd);
xfree(ctrlp->path);
file_close(fd);
}
-void
-file_open_fd(int fd, const char *name, unsigned int type)
-{
- FD_ENTRY *fde = &fd_table[fd];
- fd_open(fd, type, name);
- commSetCloseOnExec(fd);
- xstrncpy(fde->disk.filename, name, SQUID_MAXPATHLEN);
-}
-
-
/* close a disk file. */
void
file_close(int fd)
}
static int
-diskHandleReadComplete(void *data, int retcode, int errcode)
+diskHandleReadComplete(void *data, int len, int errcode)
{
disk_ctrl_t *ctrlp = data;
dread_ctrl *ctrl_dat = ctrlp->data;
int fd = ctrlp->fd;
- int len = retcode;
errno = errcode;
xfree(data);
+ fd_bytes(fd, len, FD_READ);
if (len < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
commSetSelect(fd,
/*
- * $Id: dns.cc,v 1.32 1997/04/30 03:12:03 wessels Exp $
+ * $Id: dns.cc,v 1.33 1997/04/30 18:30:47 wessels Exp $
*
* DEBUG: section 34 Dnsserver interface
* AUTHOR: Harvest Derived
local_addr,
0,
COMM_NOCLOEXEC,
- "socket to dnsserver");
+ "dnsserver listen socket");
if (cfd == COMM_ERROR) {
debug(34, 0, "dnsOpenServer: Failed to create dnsserver\n");
return -1;
local_addr,
0, /* port */
0, /* flags */
- NULL); /* blocking! */
+ "squid <-> dnsserver");
if (sfd == COMM_ERROR)
return -1;
if (comm_connect_addr(sfd, &S) == COMM_ERROR) {
int k;
int dnssocket;
LOCAL_ARRAY(char, fd_note_buf, FD_DESC_SZ);
+ char *s;
dnsFreeMemory();
dns_child_table = xcalloc(N, sizeof(dnsserver_t *));
dns_child_table[k]->offset = 0;
dns_child_table[k]->ip_inbuf = xcalloc(DNS_INBUF_SZ, 1);
/* update fd_stat */
- sprintf(fd_note_buf, "%s #%d", prg, dns_child_table[k]->id);
+ if ((s = strrchr(prg, '/')))
+ s++;
+ else
+ s = prg;
+ sprintf(fd_note_buf, "%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);
comm_write(dnsData->outpipe,
xstrdup(shutdown_cmd),
strlen(shutdown_cmd),
- 0, /* timeout */
NULL, /* Handler */
NULL, /* Handler-data */
xfree);
}
void
-fd_close (int fd)
+fd_close(int fd)
{
FD_ENTRY *fde = &fd_table[fd];
- debug(7, 1, "fd_close: FD %3d\n", fd);
fdUpdateBiggest(fd, fde->open = FD_CLOSE);
memset(fde, '\0', sizeof(FD_ENTRY));
fde->timeout = 0;
fd_open(int fd, unsigned int type, const char *desc)
{
FD_ENTRY *fde = &fd_table[fd];
- debug(7, 1, "fd_open : FD %3d, %8.8s, %s\n",
- fd,
- fdstatTypeStr[type],
- desc ? desc : "N/A");
fde->type = type;
fdUpdateBiggest(fd, fde->open = FD_OPEN);
if (desc)
- xstrncpy(fde->desc, desc, FD_DESC_SZ);
+ xstrncpy(fde->desc, desc, FD_DESC_SZ);
}
void
FD_ENTRY *fde = &fd_table[fd];
xstrncpy(fde->desc, s, FD_DESC_SZ);
}
+
+void
+fd_bytes(int fd, int len, unsigned int type)
+{
+ FD_ENTRY *fde = &fd_table[fd];
+ if (len < 0)
+ return;
+ if (type == FD_READ)
+ fde->bytes_read += len;
+ else if (type == FD_WRITE)
+ fde->bytes_written += len;
+ else
+ fatal_dump("fd_bytes: bad type");
+}
/*
- * $Id: fqdncache.cc,v 1.49 1997/04/29 22:12:54 wessels Exp $
+ * $Id: fqdncache.cc,v 1.50 1997/04/30 18:30:50 wessels Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
len = read(fd,
dnsData->ip_inbuf + dnsData->offset,
dnsData->size - dnsData->offset);
+ fd_bytes(fd, len, FD_READ);
debug(35, 5, "fqdncache_dnsHandleRead: Result from DNS ID %d (%d bytes)\n",
dnsData->id, len);
if (len <= 0) {
comm_write(dns->outpipe,
buf,
strlen(buf),
- 0, /* timeout */
NULL, /* Handler */
NULL, /* Handler-data */
xfree);
/*
- * $Id: ftp.cc,v 1.102 1997/04/30 03:12:05 wessels Exp $
+ * $Id: ftp.cc,v 1.103 1997/04/30 18:30:50 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
}
errno = 0;
len = read(fd, buf, SQUID_TCP_SO_RCVBUF);
+ fd_bytes(fd, len, FD_READ);
debug(9, 5, "ftpReadReply: FD %d, Read %d bytes\n", fd, len);
if (len > 0) {
commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
comm_write(fd,
buf,
strlen(buf),
- 30,
ftpSendComplete,
ftpState,
put_free_8k_page);
ftpStateFree,
ftpState);
commSetTimeout(ftpState->ftp_fd,
- Config.Timeout.connect,
- ftpTimeout,
- ftpState);
+ Config.Timeout.connect,
+ ftpTimeout,
+ ftpState);
commConnectStart(ftpState->ftp_fd,
localhost,
ftpget_port,
comm_close(cfd);
close(squid_to_ftpget[0]);
close(ftpget_to_squid[1]);
- fd_open(squid_to_ftpget[1], FD_PIPE, "squid->ftpget");
- fd_open(ftpget_to_squid[0], FD_PIPE, "ftpget->squid");
+ fd_open(squid_to_ftpget[1], FD_PIPE, "squid -> ftpget");
+ fd_open(ftpget_to_squid[0], FD_PIPE, "squid <- ftpget");
commSetCloseOnExec(squid_to_ftpget[1]);
commSetCloseOnExec(ftpget_to_squid[0]);
/* if ftpget -S goes away, this handler should get called */
/*
- * $Id: gopher.cc,v 1.76 1997/04/30 03:12:06 wessels Exp $
+ * $Id: gopher.cc,v 1.77 1997/04/30 18:30:52 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
static void gopherStartComplete _PARAMS((void *datap, int status));
static PF gopherSendRequest;
static GopherStateData *CreateGopherStateData _PARAMS((void));
-static CCH gopherConnectDone;
+static CNCB gopherConnectDone;
static char def_gopher_bin[] = "www/unknown";
static char def_gopher_text[] = "text/plain";
data, 0);
/* don't install read timeout until we are below the GAP */
if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
- commSetTimeout(fd, Config.Timeout.defer, NULL, NULL);
+ commSetTimeout(fd, Config.Timeout.defer, NULL, NULL);
BIT_SET(entry->flag, READ_DEFERRED);
}
/* dont try reading again for a while */
errno = 0;
/* leave one space for \0 in gopherToHTML */
len = read(fd, buf, TEMP_BUF_SIZE - 1);
+ fd_bytes(fd, len, FD_READ);
debug(10, 5, "gopherReadReply: FD %d read len=%d\n", fd, len);
if (len > 0) {
- commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
+ commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
IOStats.Gopher.reads++;
for (clen = len - 1, bin = 0; clen; bin++)
clen >>= 1;
comm_write(fd,
buf,
strlen(buf),
- 30,
gopherSendComplete,
data,
put_free_4k_page);
/*
- * $Id: http.cc,v 1.156 1997/04/30 03:12:07 wessels Exp $
+ * $Id: http.cc,v 1.157 1997/04/30 18:30:53 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
}
errno = 0;
len = read(fd, buf, SQUID_TCP_SO_RCVBUF);
+ fd_bytes(fd, len, FD_READ);
debug(11, 5, "httpReadReply: FD %d: len %d.\n", fd, len);
if (len > 0) {
- commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
+ commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
IOStats.Http.reads++;
for (clen = len - 1, bin = 0; clen; bin++)
clen >>= 1;
comm_write(fd,
buf,
len,
- 30,
httpSendComplete,
httpState,
buftype == BUF_TYPE_8K ? put_free_8k_page : xfree);
/*
- * $Id: ident.cc,v 1.27 1997/04/29 22:12:59 wessels Exp $
+ * $Id: ident.cc,v 1.28 1997/04/30 18:30:55 wessels Exp $
*
* DEBUG: section 30 Ident (RFC 931)
* AUTHOR: Duane Wessels
static void identRequestComplete _PARAMS((int, char *, int, int, void *));
static PF identReadReply;
static PF identClose;
-static CCH identConnectDone;
+static CNCB identConnectDone;
static void identCallback _PARAMS((icpStateData * icpState));
static void
comm_write(fd,
reqbuf,
strlen(reqbuf),
- 5, /* timeout */
identRequestComplete,
icpState,
NULL);
buf[0] = '\0';
len = read(fd, buf, BUFSIZ);
+ fd_bytes(fd, len, FD_READ);
if (len > 0) {
if ((t = strchr(buf, '\r')))
*t = '\0';
/*
- * $Id: ipcache.cc,v 1.111 1997/04/29 22:13:00 wessels Exp $
+ * $Id: ipcache.cc,v 1.112 1997/04/30 18:30:56 wessels Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
len = read(fd,
dnsData->ip_inbuf + dnsData->offset,
dnsData->size - dnsData->offset);
+ fd_bytes(fd, len, FD_READ);
debug(14, 5, "ipcache_dnsHandleRead: Result from DNS ID %d (%d bytes)\n",
dnsData->id, len);
if (len <= 0) {
comm_write(dns->outpipe,
buf,
strlen(buf),
- 0, /* timeout */
NULL, /* Handler */
NULL, /* Handler-data */
xfree);
/*
- * $Id: neighbors.cc,v 1.134 1997/04/30 16:18:43 wessels Exp $
+ * $Id: neighbors.cc,v 1.135 1997/04/30 18:30:57 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
return;
request->hierarchy.code = code;
if (icpdata)
- request->hierarchy.icp = *icpdata;
+ request->hierarchy.icp = *icpdata;
request->hierarchy.host = xstrdup(cache_host);
request->hierarchy.icp.stop = current_time;
}
/* only do source_ping if we have neighbors */
if (Peers.n) {
- if (Config.sourcePing) {
+ if (!Config.sourcePing) {
debug(15, 6, "neighborsUdpPing: Source Ping is disabled.\n");
} else if ((ia = ipcache_gethostbyname(host, 0))) {
debug(15, 6, "neighborsUdpPing: Source Ping: to %s for '%s'\n",
/* if we reach here, source-ping reply is the first 'parent',
* so fetch directly from the source */
debug(15, 6, "Source is the first to respond.\n");
- hierarchyNote(entry->mem_obj->request,
- SOURCE_FASTEST,
- 0,
- fqdnFromAddr(from->sin_addr));
- entry->ping_status = PING_DONE;
- protoStart(0, entry, NULL, entry->mem_obj->request);
- return;
+ mem->icp_reply_callback(NULL, ntype, opcode, mem->ircb_data);
}
} else if (opcode == ICP_OP_MISS) {
if (e == NULL) {
{
ps_state *psstate = data;
psstate->icp.n_recv++;
- debug(0, 0, "peerCountHandleIcpReply: %d replies\n", psstate->icp.n_recv);
}
/*
- * $Id: peer_select.cc,v 1.10 1997/04/29 22:13:04 wessels Exp $
+ * $Id: peer_select.cc,v 1.11 1997/04/30 18:30:58 wessels Exp $
*
* DEBUG: section 44 Peer Selection Algorithm
* AUTHOR: Duane Wessels
SOURCE_FASTEST,
&psstate->icp,
request->host);
- peerSelectCallback(psstate, p);
+ peerSelectCallback(psstate, NULL);
return;
}
if (psstate->icp.n_recv < psstate->icp.n_replies_expected)
/*
- * $Id: redirect.cc,v 1.38 1997/04/30 03:12:12 wessels Exp $
+ * $Id: redirect.cc,v 1.39 1997/04/30 18:30:59 wessels Exp $
*
* DEBUG: section 29 Redirector
* AUTHOR: Duane Wessels
comm_close(sfd);
return -1;
}
- commSetTimeout(sfd, -1, NULL, NULL);
+ commSetTimeout(sfd, -1, NULL, NULL);
debug(29, 4, "redirect_create_redirector: FD %d connected to %s #%d.\n",
sfd, command, ++n_redirector);
slp.tv_sec = 0;
len = read(fd,
redirector->inbuf + redirector->offset,
redirector->size - redirector->offset);
+ fd_bytes(fd, len, FD_READ);
debug(29, 5, "redirectHandleRead: %d bytes from Redirector #%d.\n",
len, redirector->index + 1);
if (len <= 0) {
comm_write(redirect->fd,
buf,
len,
- 0, /* timeout */
NULL, /* Handler */
NULL, /* Handler-data */
put_free_8k_page);
int redirectsocket;
LOCAL_ARRAY(char, fd_note_buf, FD_DESC_SZ);
static int first_time = 0;
+ char *s;
redirectFreeMemory();
if (Config.Program.redirect == NULL)
redirect_child_table[k]->inbuf = get_free_8k_page();
redirect_child_table[k]->size = 8192;
redirect_child_table[k]->offset = 0;
+ if ((s = strrchr(prg, '/')))
+ s++;
+ else
+ s = prg;
sprintf(fd_note_buf, "%s #%d",
- prg,
+ s,
redirect_child_table[k]->index + 1);
fd_note(redirect_child_table[k]->fd, fd_note_buf);
commSetNonBlocking(redirect_child_table[k]->fd);
/*
- * $Id: send-announce.cc,v 1.31 1997/04/28 05:32:48 wessels Exp $
+ * $Id: send-announce.cc,v 1.32 1997/04/30 18:31:00 wessels Exp $
*
* DEBUG: section 27 Cache Announcer
* AUTHOR: Duane Wessels
if ((file = Config.Announce.file)) {
fd = file_open(file, NULL, O_RDONLY, NULL, NULL);
if (fd > -1 && (n = read(fd, sndbuf + l, BUFSIZ - l - 1)) > 0) {
+ fd_bytes(fd, n, FD_READ);
l += n;
sndbuf[l] = '\0';
file_close(fd);
/*
- * $Id: squid.h,v 1.106 1997/04/29 23:34:52 wessels Exp $
+ * $Id: squid.h,v 1.107 1997/04/30 18:31:00 wessels Exp $
*
* AUTHOR: Duane Wessels
*
typedef int QS _PARAMS((const void *, const void *)); /* qsort */
#include "cache_cf.h"
+#include "fd.h"
#include "comm.h"
#include "disk.h"
-#include "fd.h"
#include "debug.h"
#include "fdstat.h"
#include "hash.h"
/*
- * $Id: ssl.cc,v 1.46 1997/04/30 03:12:12 wessels Exp $
+ * $Id: ssl.cc,v 1.47 1997/04/30 18:31:01 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
SslStateData *sslState = data;
int len;
len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF);
+ fd_bytes(sslState->server.fd, len, FD_READ);
debug(26, 5, "sslReadServer FD %d, read %d bytes\n", fd, len);
if (len < 0) {
debug(50, 1, "sslReadServer: FD %d: read failure: %s\n",
} else {
sslState->server.offset = 0;
sslState->server.len = len;
- /* extend server read timeout */
- commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL);
+ /* extend server read timeout */
+ commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL);
commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
sslWriteClient,
SslStateData *sslState = data;
int len;
len = read(sslState->client.fd, sslState->client.buf, SQUID_TCP_SO_RCVBUF);
+ fd_bytes(sslState->client.fd, len, FD_READ);
debug(26, 5, "sslReadClient FD %d, read %d bytes\n",
sslState->client.fd, len);
if (len < 0) {
comm_write(sslState->client.fd,
xstrdup(buf),
strlen(buf),
- 30,
sslErrorComplete,
sslState,
xfree);
sslState->client.fd,
sslState->server.fd);
commSetTimeout(sslState->server.fd,
- Config.Timeout.read,
- sslTimeout,
- sslState);
+ Config.Timeout.read,
+ sslTimeout,
+ sslState);
commConnectStart(fd,
sslState->host,
sslState->port,
comm_write(sslState->client.fd,
xstrdup(buf),
strlen(buf),
- 30,
sslErrorComplete,
sslState,
xfree);
comm_write(fd,
xstrdup(buf),
strlen(buf),
- 30,
NULL,
NULL,
xfree);
sslClientClosed,
sslState);
commSetTimeout(sslState->client.fd,
- Config.Timeout.lifetime,
- sslTimeout,
- sslState);
+ Config.Timeout.lifetime,
+ sslTimeout,
+ sslState);
peerSelect(request,
NULL,
sslPeerSelectComplete,
/*
- * $Id: stat.cc,v 1.137 1997/04/30 03:12:14 wessels Exp $
+ * $Id: stat.cc,v 1.138 1997/04/30 18:31:02 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
#endif
static const char *
-host_port_fmt(const char *host, u_short port)
+fdRemoteAddr(const FD_ENTRY * f)
{
LOCAL_ARRAY(char, buf, 32);
- sprintf(buf, "%s.%d", host, (int) port);
+ if (f->type != FD_SOCKET)
+ return null_string;
+ sprintf(buf, "%s.%d", f->ipaddr, (int) f->remote_port);
return buf;
}
statFiledescriptors(StoreEntry * sentry)
{
int i;
- int to = 0;
FD_ENTRY *f;
storeAppendPrintf(sentry, open_bracket);
storeAppendPrintf(sentry, "{Active file descriptors:}\n");
- storeAppendPrintf(sentry, "{%-4s %-6s %-4s %-4s %-21s %s}\n",
+ storeAppendPrintf(sentry, "{%-4s %-6s %-4s %-7s %-7s %-21s %s}\n",
"File",
"Type",
- "Lftm",
"Tout",
+ "Nread",
+ "Nwrite",
"Remote Address",
"Description");
- storeAppendPrintf(sentry, "{---- ------ ---- ---- --------------------- ------------------------------}\n");
+ storeAppendPrintf(sentry, "{---- ------ ---- ------- ------- --------------------- ------------------------------}\n");
for (i = 0; i < Squid_MaxFD; i++) {
f = &fd_table[i];
if (!f->open)
continue;
- storeAppendPrintf(sentry, "{%4d %-6s ",
+ storeAppendPrintf(sentry, "{%4d %-6.6s %4d %7d %7d %-21s %s}\n",
i,
- fdstatTypeStr[f->type]);
- switch (f->type) {
- case FD_SOCKET:
- if (f->timeout > 0)
- to = (int) (f->timeout - squid_curtime) / 60;
- if (f->timeout_handler == NULL)
- to = 0;
- storeAppendPrintf(sentry, "%4d %-21s %s}\n",
- to,
- host_port_fmt(f->ipaddr, f->remote_port),
- f->desc);
- break;
- case FD_FILE:
- storeAppendPrintf(sentry, "%31s %s}\n",
- null_string,
- f->disk.filename);
- break;
- case FD_PIPE:
- storeAppendPrintf(sentry, "%31s %s}\n", null_string, f->desc);
- break;
- case FD_LOG:
- storeAppendPrintf(sentry, "%31s %s}\n", null_string, f->desc);
- break;
- case FD_UNKNOWN:
- default:
- storeAppendPrintf(sentry, "%31s %s}\n", null_string, f->desc);
- break;
- }
+ fdstatTypeStr[f->type],
+ f->timeout_handler ? (f->timeout - squid_curtime) / 60 : 0,
+ f->bytes_read,
+ f->bytes_written,
+ fdRemoteAddr(f),
+ f->desc);
}
storeAppendPrintf(sentry, close_bracket);
}
debug(20, 1, "Rebuilding storage from %s\n", swaplog_path);
/* close the existing write-only FD */
if (SD->swaplog_fd >= 0)
- file_close(SD->swaplog_fd);
+ file_close(SD->swaplog_fd);
/* open a write-only FD for the new log */
fd = file_open(new_path, NULL, O_WRONLY | O_CREAT, NULL, NULL);
if (fd < 0) {
/*
- * $Id: tools.cc,v 1.101 1997/04/30 03:12:15 wessels Exp $
+ * $Id: tools.cc,v 1.102 1997/04/30 18:31:03 wessels Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
FD_ENTRY *f = NULL;
int i;
for (i = Biggest_FD; i >= 0; i--) {
- f = &fd_table[i];
- if (!f->read_handler && !f->write_handler)
- continue;
- if (f->type != FD_SOCKET)
- continue;
- if (f->timeout > 0 && (int) (f->timeout - squid_curtime) <= to)
- continue;
- commSetTimeout(i,
- to,
- f->timeout_handler ? f->timeout_handler : shutdownTimeoutHandler,
- f->timeout_data);
+ f = &fd_table[i];
+ if (!f->read_handler && !f->write_handler)
+ continue;
+ if (f->type != FD_SOCKET)
+ continue;
+ if (f->timeout > 0 && (int) (f->timeout - squid_curtime) <= to)
+ continue;
+ commSetTimeout(i,
+ to,
+ f->timeout_handler ? f->timeout_handler : shutdownTimeoutHandler,
+ f->timeout_data);
}
}
statCloseLog();
#if PURIFY
configFreeMemory();
- diskFreeMemory();
storeFreeMemory();
commFreeMemory();
- filemapFreeMemory();
dnsFreeMemory();
redirectFreeMemory();
errorpageFreeMemory();
/*
- * $Id: tunnel.cc,v 1.46 1997/04/30 03:12:12 wessels Exp $
+ * $Id: tunnel.cc,v 1.47 1997/04/30 18:31:01 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
SslStateData *sslState = data;
int len;
len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF);
+ fd_bytes(sslState->server.fd, len, FD_READ);
debug(26, 5, "sslReadServer FD %d, read %d bytes\n", fd, len);
if (len < 0) {
debug(50, 1, "sslReadServer: FD %d: read failure: %s\n",
} else {
sslState->server.offset = 0;
sslState->server.len = len;
- /* extend server read timeout */
- commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL);
+ /* extend server read timeout */
+ commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL);
commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
sslWriteClient,
SslStateData *sslState = data;
int len;
len = read(sslState->client.fd, sslState->client.buf, SQUID_TCP_SO_RCVBUF);
+ fd_bytes(sslState->client.fd, len, FD_READ);
debug(26, 5, "sslReadClient FD %d, read %d bytes\n",
sslState->client.fd, len);
if (len < 0) {
comm_write(sslState->client.fd,
xstrdup(buf),
strlen(buf),
- 30,
sslErrorComplete,
sslState,
xfree);
sslState->client.fd,
sslState->server.fd);
commSetTimeout(sslState->server.fd,
- Config.Timeout.read,
- sslTimeout,
- sslState);
+ Config.Timeout.read,
+ sslTimeout,
+ sslState);
commConnectStart(fd,
sslState->host,
sslState->port,
comm_write(sslState->client.fd,
xstrdup(buf),
strlen(buf),
- 30,
sslErrorComplete,
sslState,
xfree);
comm_write(fd,
xstrdup(buf),
strlen(buf),
- 30,
NULL,
NULL,
xfree);
sslClientClosed,
sslState);
commSetTimeout(sslState->client.fd,
- Config.Timeout.lifetime,
- sslTimeout,
- sslState);
+ Config.Timeout.lifetime,
+ sslTimeout,
+ sslState);
peerSelect(request,
NULL,
sslPeerSelectComplete,
/*
- * $Id: unlinkd.cc,v 1.3 1997/04/30 03:12:16 wessels Exp $
+ * $Id: unlinkd.cc,v 1.4 1997/04/30 18:31:04 wessels Exp $
*
* DEBUG: section 43 Unlink Daemon
* AUTHOR: Duane Wessels
close(wfd2);
memset(buf, '\0', HELLO_BUFSIZ);
n = read(rfd2, buf, HELLO_BUFSIZ - 1);
+ fd_bytes(rfd2, len, FD_READ);
close(rfd2);
if (n <= 0) {
debug(50, 0, "unlinkdCreate: handshake failed\n");
slp.tv_sec = 0;
slp.tv_usec = 250000;
select(0, NULL, NULL, NULL, &slp);
- file_open_fd(wfd1, "unlinkd socket", FD_PIPE);
+ fd_open(wfd1, FD_PIPE, "squid -> unlinkd");
commSetNonBlocking(wfd1);
return wfd1;
}
unlinkd_fd = unlinkdCreate();
if (unlinkd_fd < 0)
fatal("unlinkdInit: failed to start unlinkd\n");
- fd_note(unlinkd_fd, Config.Program.unlinkd);
debug(43, 0, "Unlinkd pipe opened on FD %d\n", unlinkd_fd);
}
/*
- * $Id: wais.cc,v 1.66 1997/04/30 03:12:17 wessels Exp $
+ * $Id: wais.cc,v 1.67 1997/04/30 18:31:05 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
static void waisSendComplete _PARAMS((int, char *, int, int, void *));
static PF waisSendRequest;
static void waisConnect _PARAMS((int, const ipcache_addrs *, void *));
-static CCH waisConnectDone;
+static CNCB waisConnectDone;
static void
waisStateFree(int fd, void *data)
BIT_RESET(entry->flag, READ_DEFERRED);
}
len = read(fd, buf, 4096);
+ fd_bytes(fd, len, FD_READ);
debug(24, 5, "waisReadReply: FD %d read len:%d\n", fd, len);
if (len > 0) {
commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
comm_write(fd,
buf,
len,
- 30,
waisSendComplete,
(void *) waisState,
xfree);