From: wessels <> Date: Thu, 1 May 1997 00:30:42 +0000 (+0000) Subject: more random massive changes X-Git-Tag: SQUID_3_0_PRE1~5035 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f92c80c2de644e024a477c30ff9643e1029b1d6;p=thirdparty%2Fsquid.git more random massive changes --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index f5bb04abbe..8eda60afc1 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -124,12 +124,12 @@ struct SquidConfig Config; #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 */ @@ -1026,16 +1026,16 @@ parseConfigFile(const char *file_name) 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")) diff --git a/src/client_side.cc b/src/client_side.cc index f17b5fec37..89c6507199 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -571,7 +571,6 @@ clientPurgeRequest(icpStateData * icpState) comm_write(fd, msg, strlen(msg), - 30, icpSendERRORComplete, icpState, NULL); diff --git a/src/comm.cc b/src/comm.cc index f67bfb219c..dd6e5bd6ce 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -120,16 +120,14 @@ int RESERVED_FD = 64; #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 */ @@ -171,7 +169,7 @@ static void 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; @@ -313,7 +311,7 @@ comm_listen(int sock) } 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); @@ -375,28 +373,28 @@ commConnectHandle(int fd, void *data) } } 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; } @@ -524,9 +522,9 @@ comm_close(int fd) 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; @@ -1063,18 +1061,18 @@ commSetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t { 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 @@ -1194,17 +1192,10 @@ commSetNonBlocking(int fd) 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; } @@ -1329,7 +1320,6 @@ checkTimeouts(void) 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; @@ -1432,7 +1422,7 @@ commHandleWrite(int fd, void *data) /* 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; @@ -1448,8 +1438,6 @@ comm_write(int fd, char *buf, int size, int timeout, rw_complete_handler * handl 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; diff --git a/src/disk.cc b/src/disk.cc index 134331b599..801ade6939 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -160,11 +160,7 @@ file_open(const char *path, int (*handler) _PARAMS((void)), int mode, void (*cal 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 @@ -205,7 +201,6 @@ file_open_complete(void *data, int fd, int errcode) 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); @@ -242,16 +237,6 @@ file_must_close(int fd) 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) @@ -479,14 +464,14 @@ diskHandleRead(int fd, void *data) } 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, diff --git a/src/dns.cc b/src/dns.cc index 76a3a21fe1..bdb1bf2bba 100644 --- a/src/dns.cc +++ b/src/dns.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -134,7 +134,7 @@ dnsOpenServer(const char *command) 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; @@ -160,7 +160,7 @@ dnsOpenServer(const char *command) local_addr, 0, /* port */ 0, /* flags */ - NULL); /* blocking! */ + "squid <-> dnsserver"); if (sfd == COMM_ERROR) return -1; if (comm_connect_addr(sfd, &S) == COMM_ERROR) { @@ -247,6 +247,7 @@ dnsOpenServers(void) int k; int dnssocket; LOCAL_ARRAY(char, fd_note_buf, FD_DESC_SZ); + char *s; dnsFreeMemory(); dns_child_table = xcalloc(N, sizeof(dnsserver_t *)); @@ -272,7 +273,11 @@ dnsOpenServers(void) 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); @@ -362,7 +367,6 @@ dnsShutdownServers(void) comm_write(dnsData->outpipe, xstrdup(shutdown_cmd), strlen(shutdown_cmd), - 0, /* timeout */ NULL, /* Handler */ NULL, /* Handler-data */ xfree); diff --git a/src/fd.cc b/src/fd.cc index 24e11b4d04..44cfc3f049 100644 --- a/src/fd.cc +++ b/src/fd.cc @@ -28,10 +28,9 @@ fdUpdateBiggest(int fd, unsigned int status) } 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; @@ -41,14 +40,10 @@ void 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 @@ -57,3 +52,17 @@ fd_note(int fd, const char *s) 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"); +} diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 05ac42e0b6..72f073fc35 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -534,6 +534,7 @@ fqdncache_dnsHandleRead(int fd, void *data) 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) { @@ -703,7 +704,6 @@ fqdncache_dnsDispatch(dnsserver_t * dns, fqdncache_entry * f) comm_write(dns->outpipe, buf, strlen(buf), - 0, /* timeout */ NULL, /* Handler */ NULL, /* Handler-data */ xfree); diff --git a/src/ftp.cc b/src/ftp.cc index 79d917b156..e8f167946f 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -313,6 +313,7 @@ ftpReadReply(int fd, void *data) } 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); @@ -504,7 +505,6 @@ ftpSendRequest(int fd, void *data) comm_write(fd, buf, strlen(buf), - 30, ftpSendComplete, ftpState, put_free_8k_page); @@ -627,9 +627,9 @@ ftpStartComplete(void *data, int status) ftpStateFree, ftpState); commSetTimeout(ftpState->ftp_fd, - Config.Timeout.connect, - ftpTimeout, - ftpState); + Config.Timeout.connect, + ftpTimeout, + ftpState); commConnectStart(ftpState->ftp_fd, localhost, ftpget_port, @@ -750,8 +750,8 @@ ftpInitialize(void) 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 */ diff --git a/src/gopher.cc b/src/gopher.cc index c284fb1a4b..adc8a47d01 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -178,7 +178,7 @@ static void gopherSendComplete(int fd, 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"; @@ -727,7 +727,7 @@ gopherReadReply(int fd, void *data) 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 */ @@ -740,9 +740,10 @@ gopherReadReply(int fd, void *data) 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; @@ -890,7 +891,6 @@ gopherSendRequest(int fd, void *data) comm_write(fd, buf, strlen(buf), - 30, gopherSendComplete, data, put_free_4k_page); diff --git a/src/http.cc b/src/http.cc index 4276f3038c..e8c46784ff 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -587,9 +587,10 @@ httpReadReply(int fd, void *data) } 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; @@ -844,7 +845,6 @@ httpSendRequest(int fd, void *data) comm_write(fd, buf, len, - 30, httpSendComplete, httpState, buftype == BUF_TYPE_8K ? put_free_8k_page : xfree); diff --git a/src/ident.cc b/src/ident.cc index 4b6abe704a..03eff38c5c 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -35,7 +35,7 @@ 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 @@ -90,7 +90,6 @@ identConnectDone(int fd, int status, void *data) comm_write(fd, reqbuf, strlen(reqbuf), - 5, /* timeout */ identRequestComplete, icpState, NULL); @@ -116,6 +115,7 @@ identReadReply(int fd, void *data) buf[0] = '\0'; len = read(fd, buf, BUFSIZ); + fd_bytes(fd, len, FD_READ); if (len > 0) { if ((t = strchr(buf, '\r'))) *t = '\0'; diff --git a/src/ipcache.cc b/src/ipcache.cc index 3833207f99..f3b68b3e77 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -554,6 +554,7 @@ ipcache_dnsHandleRead(int fd, void *data) 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) { @@ -724,7 +725,6 @@ ipcache_dnsDispatch(dnsserver_t * dns, ipcache_entry * i) comm_write(dns->outpipe, buf, strlen(buf), - 0, /* timeout */ NULL, /* Handler */ NULL, /* Handler-data */ xfree); diff --git a/src/neighbors.cc b/src/neighbors.cc index 5ebd95031d..59ca107155 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -181,7 +181,7 @@ hierarchyNote(request_t * request, 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; } @@ -540,7 +540,7 @@ neighborsUdpPing(request_t * request, /* 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", @@ -679,13 +679,7 @@ neighborsUdpAck(int fd, const char *url, icp_common_t * header, const struct soc /* 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) { @@ -1122,5 +1116,4 @@ peerCountHandleIcpReply(peer * p, peer_t type, icp_opcode op, void *data) { ps_state *psstate = data; psstate->icp.n_recv++; - debug(0, 0, "peerCountHandleIcpReply: %d replies\n", psstate->icp.n_recv); } diff --git a/src/peer_select.cc b/src/peer_select.cc index 57a5668c3c..0eb6f43119 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -310,7 +310,7 @@ peerHandleIcpReply(peer * p, peer_t type, icp_opcode op, void *data) SOURCE_FASTEST, &psstate->icp, request->host); - peerSelectCallback(psstate, p); + peerSelectCallback(psstate, NULL); return; } if (psstate->icp.n_recv < psstate->icp.n_replies_expected) diff --git a/src/redirect.cc b/src/redirect.cc index 472cee99fc..c2d731b015 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -133,7 +133,7 @@ redirectCreateRedirector(const char *command) 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; @@ -173,6 +173,7 @@ redirectHandleRead(int fd, void *data) 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) { @@ -307,7 +308,6 @@ redirectDispatch(redirector_t * redirect, redirectStateData * r) comm_write(redirect->fd, buf, len, - 0, /* timeout */ NULL, /* Handler */ NULL, /* Handler-data */ put_free_8k_page); @@ -376,6 +376,7 @@ redirectOpenServers(void) int redirectsocket; LOCAL_ARRAY(char, fd_note_buf, FD_DESC_SZ); static int first_time = 0; + char *s; redirectFreeMemory(); if (Config.Program.redirect == NULL) @@ -396,8 +397,12 @@ redirectOpenServers(void) 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); diff --git a/src/send-announce.cc b/src/send-announce.cc index 7e2db727b9..7ff6d0911b 100644 --- a/src/send-announce.cc +++ b/src/send-announce.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -79,6 +79,7 @@ send_announce(int fd, const ipcache_addrs * ia, void *data) 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); diff --git a/src/squid.h b/src/squid.h index 6cd2e74f48..6e83d02dd1 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $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 * @@ -269,9 +269,9 @@ typedef void SIH _PARAMS((void *, int)); /* swap in */ 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" diff --git a/src/ssl.cc b/src/ssl.cc index d1287471f4..4a63807682 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -130,6 +130,7 @@ sslReadServer(int fd, void *data) 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", @@ -150,8 +151,8 @@ sslReadServer(int fd, void *data) } 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, @@ -166,6 +167,7 @@ sslReadClient(int fd, void *data) 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) { @@ -333,7 +335,6 @@ sslConnect(int fd, const ipcache_addrs * ia, void *data) comm_write(sslState->client.fd, xstrdup(buf), strlen(buf), - 30, sslErrorComplete, sslState, xfree); @@ -343,9 +344,9 @@ sslConnect(int fd, const ipcache_addrs * ia, void *data) 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, @@ -368,7 +369,6 @@ sslConnectDone(int fd, int status, void *data) comm_write(sslState->client.fd, xstrdup(buf), strlen(buf), - 30, sslErrorComplete, sslState, xfree); @@ -409,7 +409,6 @@ sslStart(int fd, const char *url, request_t * request, char *mime_hdr, int *size comm_write(fd, xstrdup(buf), strlen(buf), - 30, NULL, NULL, xfree); @@ -432,9 +431,9 @@ sslStart(int fd, const char *url, request_t * request, char *mime_hdr, int *size sslClientClosed, sslState); commSetTimeout(sslState->client.fd, - Config.Timeout.lifetime, - sslTimeout, - sslState); + Config.Timeout.lifetime, + sslTimeout, + sslState); peerSelect(request, NULL, sslPeerSelectComplete, diff --git a/src/stat.cc b/src/stat.cc index 470f1ab79c..54c24e1f91 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -620,10 +620,12 @@ info_get_mallstat(int size, int number, StoreEntry * sentry) #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; } @@ -631,53 +633,31 @@ static void 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); } diff --git a/src/store_dir.cc b/src/store_dir.cc index dd5c25da49..accd04c9f1 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -310,7 +310,7 @@ storeDirOpenTmpSwapLog(int dirn, int *clean_flag) 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) { diff --git a/src/tools.cc b/src/tools.cc index 17e614b255..92b8de1c38 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -330,17 +330,17 @@ setSocketShutdownLifetimes(int to) 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); } } @@ -361,10 +361,8 @@ normal_shutdown(void) statCloseLog(); #if PURIFY configFreeMemory(); - diskFreeMemory(); storeFreeMemory(); commFreeMemory(); - filemapFreeMemory(); dnsFreeMemory(); redirectFreeMemory(); errorpageFreeMemory(); diff --git a/src/tunnel.cc b/src/tunnel.cc index 17ca5bc426..3c7babc7f6 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -130,6 +130,7 @@ sslReadServer(int fd, void *data) 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", @@ -150,8 +151,8 @@ sslReadServer(int fd, void *data) } 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, @@ -166,6 +167,7 @@ sslReadClient(int fd, void *data) 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) { @@ -333,7 +335,6 @@ sslConnect(int fd, const ipcache_addrs * ia, void *data) comm_write(sslState->client.fd, xstrdup(buf), strlen(buf), - 30, sslErrorComplete, sslState, xfree); @@ -343,9 +344,9 @@ sslConnect(int fd, const ipcache_addrs * ia, void *data) 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, @@ -368,7 +369,6 @@ sslConnectDone(int fd, int status, void *data) comm_write(sslState->client.fd, xstrdup(buf), strlen(buf), - 30, sslErrorComplete, sslState, xfree); @@ -409,7 +409,6 @@ sslStart(int fd, const char *url, request_t * request, char *mime_hdr, int *size comm_write(fd, xstrdup(buf), strlen(buf), - 30, NULL, NULL, xfree); @@ -432,9 +431,9 @@ sslStart(int fd, const char *url, request_t * request, char *mime_hdr, int *size sslClientClosed, sslState); commSetTimeout(sslState->client.fd, - Config.Timeout.lifetime, - sslTimeout, - sslState); + Config.Timeout.lifetime, + sslTimeout, + sslState); peerSelect(request, NULL, sslPeerSelectComplete, diff --git a/src/unlinkd.cc b/src/unlinkd.cc index d6fbd422d3..c906b6fef6 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -1,5 +1,5 @@ /* - * $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 @@ -116,6 +116,7 @@ unlinkdCreate(void) 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"); @@ -131,7 +132,7 @@ unlinkdCreate(void) 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; } @@ -192,7 +193,6 @@ unlinkdInit(void) 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); } diff --git a/src/wais.cc b/src/wais.cc index 7a601737cf..5130282e8b 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -126,7 +126,7 @@ static PF waisReadReply; 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) @@ -203,6 +203,7 @@ waisReadReply(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); @@ -291,7 +292,6 @@ waisSendRequest(int fd, void *data) comm_write(fd, buf, len, - 30, waisSendComplete, (void *) waisState, xfree);