From: wessels <> Date: Thu, 19 Sep 1996 02:12:16 +0000 (+0000) Subject: - Added 'cache_stoplist' to specify things which should X-Git-Tag: SQUID_3_0_PRE1~5770 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b15fe823d6affb1f76c092a2cf9472b190f82dc6;p=thirdparty%2Fsquid.git - Added 'cache_stoplist' to specify things which should never get saved to disk. - Merged some parsing routines into parseWordlist(). - Fixed icpHandleIMSReply() bug when HTTP reply headers received in multiple reads. - Changed all ipcache_nbgethostbyname() handler functions to be void. - Fixed bug when storeLockObject() fails for UDP_HIT_OBJ replies. - Simplified storeGet(). - Removed meta_data.hash_links member. --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index bd14ccf2a9..95af3ee0db 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,5 +1,5 @@ /* - * $Id: cache_cf.cc,v 1.91 1996/09/17 16:32:32 wessels Exp $ + * $Id: cache_cf.cc,v 1.92 1996/09/18 20:12:16 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -222,9 +222,7 @@ static void parseAppendDomainLine __P((void)); static void parseCacheAnnounceLine __P((void)); static void parseCacheHostLine __P((void)); static void parseDebugOptionsLine __P((void)); -static void parseDirLine __P((void)); static void parseDnsProgramLine __P((void)); -static void parseDnsTestnameLine __P((void)); static void parseEffectiveUserLine __P((void)); static void parseErrHtmlLine __P((void)); static void parseFtpLine __P((void)); @@ -232,7 +230,7 @@ static void parseFtpOptionsLine __P((void)); static void parseFtpProgramLine __P((void)); static void parseFtpUserLine __P((void)); static void parseGopherLine __P((void)); -static void parseHierarchyStoplistLine __P((void)); +static void parseWordlist __P((wordlist **)); static void parseHostAclLine __P((void)); static void parseHostDomainLine __P((void)); static void parseHotVmFactorLine __P((void)); @@ -241,7 +239,6 @@ static void parseHttpPortLine __P((void)); static void parseHttpdAccelLine __P((void)); static void parseIPLine __P((ip_acl ** list)); static void parseIcpPortLine __P((void)); -static void parseInsideFirewallLine __P((void)); static void parseLocalDomainFile __P((char *fname)); static void parseLocalDomainLine __P((void)); static void parseLogLine __P((void)); @@ -665,17 +662,6 @@ parseMgrLine(void) Config.adminEmail = xstrdup(token); } -static void -parseDirLine(void) -{ - char *token; - - token = strtok(NULL, w_space); - if (token == NULL) - self_destruct(); - wordlistAdd(&Config.cache_dirs, token); -} - #if USE_PROXY_AUTH static void parseProxyAuthLine(void) @@ -847,11 +833,11 @@ parseIPLine(ip_acl ** list) } static void -parseHierarchyStoplistLine(void) +parseWordlist(wordlist **list) { char *token; while ((token = strtok(NULL, w_space))) - wordlistAdd(&Config.hierarchy_stoplist, token); + wordlistAdd(list, token); } static void @@ -924,24 +910,6 @@ parseLocalDomainLine(void) } } -static void -parseInsideFirewallLine(void) -{ - char *token; - while ((token = strtok(NULL, w_space))) { - wordlistAdd(&Config.inside_firewall_list, token); - } -} - -static void -parseDnsTestnameLine(void) -{ - char *token; - while ((token = strtok(NULL, w_space))) { - wordlistAdd(&Config.dns_testname_list, token); - } -} - static void parseHttpPortLine(void) { @@ -1126,7 +1094,7 @@ parseConfigFile(char *file_name) parseIntegerValue(&Config.neighborTimeout); else if (!strcmp(token, "cache_dir")) - parseDirLine(); + parseWordlist(&Config.cache_dirs); else if (!strcmp(token, "cache_log")) parseLogLine(); @@ -1186,7 +1154,10 @@ parseConfigFile(char *file_name) aclParseAccessLine(&ICPAccessList); else if (!strcmp(token, "hierarchy_stoplist")) - parseHierarchyStoplistLine(); + parseWordlist(&Config.hierarchy_stoplist); + + else if (!strcmp(token, "cache_stoplist")) + parseWordlist(&Config.cache_stoplist); else if (!strcmp(token, "gopher")) parseGopherLine(); @@ -1319,10 +1290,10 @@ parseConfigFile(char *file_name) parseIcpPortLine(); else if (!strcmp(token, "inside_firewall")) - parseInsideFirewallLine(); + parseWordlist(&Config.inside_firewall_list); else if (!strcmp(token, "dns_testnames")) - parseDnsTestnameLine(); + parseWordlist(&Config.dns_testname_list); else if (!strcmp(token, "single_parent_bypass")) parseOnOff(&Config.singleParentBypass); diff --git a/src/client_side.cc b/src/client_side.cc index 5a4e2d8fe9..41ffa979c8 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.30 1996/09/17 16:32:34 wessels Exp $ + * $Id: client_side.cc,v 1.31 1996/09/18 20:12:17 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -392,7 +392,7 @@ icpHandleIMSReply(int fd, StoreEntry * entry, void *data) { icpStateData *icpState = data; MemObject *mem = entry->mem_obj; - LOCAL_ARRAY(char, hbuf, 8192); + char *hbuf; int len; int unlink_request = 0; debug(33, 3, "icpHandleIMSReply: FD %d '%s'\n", fd, entry->url); @@ -408,6 +408,15 @@ icpHandleIMSReply(int fd, StoreEntry * entry, void *data) 400); return 0; } + if (mem->reply->code == 0) { + debug(33,0,"icpHandleIMSReply: Incomplete headers for '%s'\n", + entry->url); + storeRegister(entry, + fd, + (PIF) icpHandleIMSReply, + (void *) icpState); + return 0; + } if (mem->reply->code == 304 && !BIT_TEST(icpState->flags, REQ_IMS)) { icpState->log_type = LOG_TCP_EXPIRED_HIT; /* We initiated the IMS request, the client is not expecting @@ -421,10 +430,12 @@ icpHandleIMSReply(int fd, StoreEntry * entry, void *data) /* Extend the TTL * XXX race condition here. Assumes old_entry has been swapped * in by the time this 304 reply arrives. */ + hbuf = get_free_8k_page(); storeClientCopy(entry, 0, 8191, hbuf, &len, fd); if (!mime_headers_end(hbuf)) fatal_dump("icpHandleIMSReply: failed to load headers, lost race"); httpParseHeaders(hbuf, entry->mem_obj->reply); + put_free_8k_page(hbuf); ttlSet(entry); if (unlink_request) { requestUnlink(entry->mem_obj->request); diff --git a/src/http.cc b/src/http.cc index 67c3396569..db2d13fc76 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,5 +1,5 @@ /* - * $Id: http.cc,v 1.76 1996/09/16 21:11:08 wessels Exp $ + * $Id: http.cc,v 1.77 1996/09/18 20:12:18 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -126,7 +126,7 @@ static void httpReadReply __P((int fd, HttpStateData *)); static void httpSendComplete __P((int fd, char *, int, int, void *)); static void httpSendRequest __P((int fd, HttpStateData *)); static void httpConnInProgress __P((int fd, HttpStateData *)); -static int httpConnect __P((int fd, struct hostent *, void *)); +static void httpConnect __P((int fd, struct hostent *, void *)); static int httpStateFree(int fd, HttpStateData * httpState) @@ -297,14 +297,11 @@ httpProcessReplyHeader(HttpStateData * httpState, char *buf, int size) if (hdr_len > 4 && strncmp(httpState->reply_hdr, "HTTP/", 5)) { debug(11, 3, "httpProcessReplyHeader: Non-HTTP-compliant header: '%s'\n", entry->key); httpState->reply_hdr_state += 2; + entry->mem_obj->reply->code = 555; return; } - /* Find the end of the headers */ - t = mime_headers_end(httpState->reply_hdr); - if (!t) - /* XXX: Here we could check for buffer overflow... */ + if ((t = mime_headers_end(httpState->reply_hdr)) == NULL) return; /* headers not complete */ - /* Cut after end of headers */ *t = '\0'; reply = entry->mem_obj->reply; reply->hdr_sz = t - httpState->reply_hdr; @@ -704,19 +701,18 @@ proxyhttpStart(edge * e, char *url, StoreEntry * entry) comm_add_close_handler(sock, (PF) httpStateFree, (void *) httpState); - request->method = entry->method; strncpy(request->host, e->host, SQUIDHOSTNAMELEN); request->port = e->http_port; strncpy(request->urlpath, url, MAX_URL); ipcache_nbgethostbyname(request->host, sock, - (IPH) httpConnect, + httpConnect, httpState); return COMM_OK; } -static int +static void httpConnect(int fd, struct hostent *hp, void *data) { HttpStateData *httpState = data; @@ -728,7 +724,7 @@ httpConnect(int fd, struct hostent *hp, void *data) debug(11, 4, "httpConnect: Unknown host: %s\n", request->host); squid_error_entry(entry, ERR_DNS_FAIL, dns_error_message); comm_close(fd); - return COMM_ERROR; + return; } /* Open connection. */ if ((status = comm_connect(fd, request->host, request->port))) { @@ -739,14 +735,14 @@ httpConnect(int fd, struct hostent *hp, void *data) e->last_fail_time = squid_curtime; e->neighbor_up = 0; } - return COMM_ERROR; + return; } else { debug(11, 5, "proxyhttpStart: FD %d: EINPROGRESS.\n", fd); comm_set_select_handler(fd, COMM_SELECT_LIFETIME, (PF) httpLifetimeExpire, (void *) httpState); comm_set_select_handler(fd, COMM_SELECT_WRITE, (PF) httpConnInProgress, (void *) httpState); - return COMM_OK; + return; } } /* Install connection complete handler. */ @@ -757,7 +753,6 @@ httpConnect(int fd, struct hostent *hp, void *data) (PF) httpLifetimeExpire, (void *) httpState); comm_set_select_handler(fd, COMM_SELECT_WRITE, (PF) httpSendRequest, (void *) httpState); - return COMM_OK; } int @@ -794,7 +789,6 @@ httpStart(int unusedfd, char *url, request_t * request, char *req_hdr, StoreEntr sock, httpConnect, httpState); - return COMM_OK; } diff --git a/src/squid.h b/src/squid.h index f68407be51..830a3474a5 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.52 1996/09/17 16:54:05 wessels Exp $ + * $Id: squid.h,v 1.53 1996/09/18 20:12:22 wessels Exp $ * * AUTHOR: Duane Wessels * @@ -250,6 +250,7 @@ typedef int (*QS) (const void *, const void *); #include "redirect.h" #include "client_side.h" #include "icmp.h" +#include "net_db.h" #if !HAVE_TEMPNAM #include "tempnam.h" diff --git a/src/ssl.cc b/src/ssl.cc index a92afbe252..d2f060b8b2 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $Id: ssl.cc,v 1.16 1996/09/16 21:11:15 wessels Exp $ + * $Id: ssl.cc,v 1.17 1996/09/18 20:12:22 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -57,7 +57,7 @@ static void sslWriteServer __P((int fd, SslStateData * sslState)); static void sslWriteClient __P((int fd, SslStateData * sslState)); static void sslConnected __P((int fd, SslStateData * sslState)); static void sslProxyConnected __P((int fd, SslStateData * sslState)); -static int sslConnect __P((int fd, struct hostent *, SslStateData *)); +static void sslConnect __P((int fd, struct hostent *, void *)); static void sslConnInProgress __P((int fd, SslStateData * sslState)); static void sslErrorComplete __P((int, char *, int, int, void *)); static void sslClose __P((SslStateData * sslState)); @@ -346,9 +346,10 @@ sslConnInProgress(int fd, SslStateData * sslState) return; } -static int -sslConnect(int fd, struct hostent *hp, SslStateData * sslState) +static void +sslConnect(int fd, struct hostent *hp, void *data) { + SslStateData *sslState = data; request_t *request = sslState->request; int status; char *buf = NULL; @@ -367,7 +368,7 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) sslErrorComplete, (void *) sslState, xfree); - return COMM_ERROR; + return; } debug(26, 5, "sslConnect: client=%d server=%d\n", sslState->client.fd, @@ -401,7 +402,7 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) sslErrorComplete, (void *) sslState, xfree); - return COMM_ERROR; + return; } else { debug(26, 5, "sslConnect: conn %d EINPROGRESS\n", fd); /* The connection is in progress, install ssl handler */ @@ -409,7 +410,7 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) COMM_SELECT_WRITE, (PF) sslConnInProgress, (void *) sslState); - return COMM_OK; + return; } } if (opt_no_ipcache) @@ -418,7 +419,6 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) sslProxyConnected(sslState->server.fd, sslState); else sslConnected(sslState->server.fd, sslState); - return COMM_OK; } int @@ -486,7 +486,7 @@ sslStart(int fd, char *url, request_t * request, char *mime_hdr, int *size_ptr) (void *) sslState); ipcache_nbgethostbyname(sslState->host, sslState->server.fd, - (IPH) sslConnect, + sslConnect, sslState); return COMM_OK; } diff --git a/src/stat.cc b/src/stat.cc index 07a81c29fd..ae0fa65a36 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.72 1996/09/17 16:32:46 wessels Exp $ + * $Id: stat.cc,v 1.73 1996/09/18 20:12:23 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -634,7 +634,7 @@ memoryAccounted(void) meta_data.store_entries * sizeof(StoreEntry) + meta_data.ipcache_count * sizeof(ipcache_entry) + meta_data.fqdncache_count * sizeof(fqdncache_entry) + - meta_data.hash_links * sizeof(hash_link) + + hash_links_allocated * sizeof(hash_link) + sm_stats.total_pages_allocated * sm_stats.page_size + disk_stats.total_pages_allocated * disk_stats.page_size + request_pool.total_pages_allocated * request_pool.page_size + @@ -796,9 +796,9 @@ info_get(cacheinfo * obj, StoreEntry * sentry) storeAppendPrintf(sentry, "{\t%-25.25s %7d x %4d bytes = %6d KB}\n", "Hash link", - meta_data.hash_links = hash_links_allocated, + hash_links_allocated, (int) sizeof(hash_link), - (int) (meta_data.hash_links * sizeof(hash_link) >> 10)); + (int) (hash_links_allocated * sizeof(hash_link) >> 10)); storeAppendPrintf(sentry, "{\t%-25.25s = %6d KB}\n", "URL strings", diff --git a/src/store.cc b/src/store.cc index 108e34d4e5..c1495eb46f 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.113 1996/09/17 02:30:05 wessels Exp $ + * $Id: store.cc,v 1.114 1996/09/18 20:12:25 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -593,13 +593,8 @@ storeUnlockObject(StoreEntry * e) StoreEntry * storeGet(char *url) { - hash_link *hptr = NULL; - debug(20, 3, "storeGet: looking up %s\n", url); - - if ((hptr = hash_lookup(store_table, url)) != NULL) - return (StoreEntry *) hptr; - return NULL; + return (StoreEntry *) hash_lookup(store_table, url); } unsigned int @@ -2140,6 +2135,7 @@ storeRelease(StoreEntry * e) debug(20, 0, "storeRelease: Not Found: '%s'\n", e->key); debug(20, 0, "Dump of Entry 'e':\n %s\n", storeToString(e)); debug_trap("storeRelease: Invalid Entry"); + return; } result = (StoreEntry *) hptr; if (result != e) { @@ -2148,6 +2144,7 @@ storeRelease(StoreEntry * e) debug(20, 0, "Dump of Entry 'e':\n%s", storeToString(e)); debug(20, 0, "Dump of Entry 'result':\n%s", storeToString(result)); debug_trap("storeRelease: Duplicate Entry"); + return; } } if (e->method == METHOD_GET) { diff --git a/src/tunnel.cc b/src/tunnel.cc index 327f6465f8..1aeff8ebf6 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.16 1996/09/16 21:11:15 wessels Exp $ + * $Id: tunnel.cc,v 1.17 1996/09/18 20:12:22 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -57,7 +57,7 @@ static void sslWriteServer __P((int fd, SslStateData * sslState)); static void sslWriteClient __P((int fd, SslStateData * sslState)); static void sslConnected __P((int fd, SslStateData * sslState)); static void sslProxyConnected __P((int fd, SslStateData * sslState)); -static int sslConnect __P((int fd, struct hostent *, SslStateData *)); +static void sslConnect __P((int fd, struct hostent *, void *)); static void sslConnInProgress __P((int fd, SslStateData * sslState)); static void sslErrorComplete __P((int, char *, int, int, void *)); static void sslClose __P((SslStateData * sslState)); @@ -346,9 +346,10 @@ sslConnInProgress(int fd, SslStateData * sslState) return; } -static int -sslConnect(int fd, struct hostent *hp, SslStateData * sslState) +static void +sslConnect(int fd, struct hostent *hp, void *data) { + SslStateData *sslState = data; request_t *request = sslState->request; int status; char *buf = NULL; @@ -367,7 +368,7 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) sslErrorComplete, (void *) sslState, xfree); - return COMM_ERROR; + return; } debug(26, 5, "sslConnect: client=%d server=%d\n", sslState->client.fd, @@ -401,7 +402,7 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) sslErrorComplete, (void *) sslState, xfree); - return COMM_ERROR; + return; } else { debug(26, 5, "sslConnect: conn %d EINPROGRESS\n", fd); /* The connection is in progress, install ssl handler */ @@ -409,7 +410,7 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) COMM_SELECT_WRITE, (PF) sslConnInProgress, (void *) sslState); - return COMM_OK; + return; } } if (opt_no_ipcache) @@ -418,7 +419,6 @@ sslConnect(int fd, struct hostent *hp, SslStateData * sslState) sslProxyConnected(sslState->server.fd, sslState); else sslConnected(sslState->server.fd, sslState); - return COMM_OK; } int @@ -486,7 +486,7 @@ sslStart(int fd, char *url, request_t * request, char *mime_hdr, int *size_ptr) (void *) sslState); ipcache_nbgethostbyname(sslState->host, sslState->server.fd, - (IPH) sslConnect, + sslConnect, sslState); return COMM_OK; } diff --git a/src/wais.cc b/src/wais.cc index e5e42754df..40f58bf3d8 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $Id: wais.cc,v 1.42 1996/09/16 21:11:17 wessels Exp $ + * $Id: wais.cc,v 1.43 1996/09/18 20:12:25 wessels Exp $ * * DEBUG: section 24 WAIS Relay * AUTHOR: Harvest Derived @@ -125,7 +125,7 @@ static void waisReadReply __P((int, WaisStateData *)); static void waisSendComplete __P((int, char *, int, int, void *)); static void waisSendRequest __P((int, WaisStateData *)); static void waisConnInProgress __P((int, WaisStateData *)); -static int waisConnect __P((int, struct hostent *, WaisStateData *)); +static void waisConnect __P((int, struct hostent *, void *)); static int waisStateFree(int fd, WaisStateData * waisState) @@ -409,30 +409,31 @@ waisStart(int unusedfd, char *url, method_t method, char *mime_hdr, StoreEntry * (void *) waisState); ipcache_nbgethostbyname(waisState->relayhost, waisState->fd, - (IPH) waisConnect, + waisConnect, waisState); return COMM_OK; } -static int -waisConnect(int fd, struct hostent *hp, WaisStateData * waisState) +static void +waisConnect(int fd, struct hostent *hp, void *data) { int status; + WaisStateData *waisState = data; char *host = waisState->relayhost; u_short port = waisState->relayport; if (!ipcache_gethostbyname(waisState->relayhost, 0)) { debug(24, 4, "waisstart: Unknown host: %s\n", waisState->relayhost); squid_error_entry(waisState->entry, ERR_DNS_FAIL, dns_error_message); comm_close(waisState->fd); - return COMM_ERROR; + return; } /* Open connection. */ if ((status = comm_connect(fd, host, port))) { if (status != EINPROGRESS) { squid_error_entry(waisState->entry, ERR_CONNECT_FAIL, xstrerror()); comm_close(fd); - return COMM_ERROR; + return; } else { debug(24, 5, "waisStart: FD %d EINPROGRESS\n", fd); comm_set_select_handler(fd, @@ -443,7 +444,7 @@ waisConnect(int fd, struct hostent *hp, WaisStateData * waisState) COMM_SELECT_WRITE, (PF) waisConnInProgress, (void *) waisState); - return COMM_OK; + return; } } /* Install connection complete handler. */ @@ -457,5 +458,4 @@ waisConnect(int fd, struct hostent *hp, WaisStateData * waisState) COMM_SELECT_WRITE, (PF) waisSendRequest, (void *) waisState); - return COMM_OK; }