From: Francesco Chemolli Date: Fri, 17 Aug 2012 09:17:46 +0000 (+0200) Subject: Moved fqdncache prototypes from protos.h to fqdncache.h X-Git-Tag: sourceformat-review-1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95e6d8649b523f834cc314bf220395286051c6eb;p=thirdparty%2Fsquid.git Moved fqdncache prototypes from protos.h to fqdncache.h --- diff --git a/src/Makefile.am b/src/Makefile.am index 56a2de0f6b..f832fdf261 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -272,6 +272,7 @@ squid_SOURCES = \ cbdata.h \ ChunkedCodingParser.cc \ ChunkedCodingParser.h \ + client_db.h \ client_db.cc \ client_side.cc \ client_side.h \ @@ -1296,6 +1297,7 @@ tests_testCacheManager_SOURCES = \ carp.cc \ cbdata.cc \ ChunkedCodingParser.cc \ + client_db.h \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -1464,6 +1466,7 @@ tests_testCacheManager_DEPENDENCIES = \ tests_testDiskIO_SOURCES = \ CacheDigest.cc \ cbdata.cc \ + client_db.h \ ClientInfo.h \ ConfigOption.cc \ ConfigParser.cc \ @@ -1618,6 +1621,7 @@ tests_testEvent_SOURCES = \ carp.cc \ cbdata.cc \ ChunkedCodingParser.cc \ + client_db.h \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -1810,6 +1814,7 @@ tests_testEventLoop_SOURCES = \ carp.cc \ cbdata.cc \ ChunkedCodingParser.cc \ + client_db.h \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -2000,6 +2005,7 @@ tests_test_http_range_SOURCES = \ carp.cc \ cbdata.cc \ ChunkedCodingParser.cc \ + client_db.h \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -2238,6 +2244,7 @@ tests_testHttpRequest_SOURCES = \ carp.cc \ cbdata.cc \ ChunkedCodingParser.cc \ + client_db.h \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -2609,6 +2616,7 @@ tests_testUfs_SOURCES = \ tests/stub_store_rebuild.cc \ tests/stub_store_stats.cc \ fd.cc \ + client_db.h \ disk.cc \ FileMap.h \ filemap.cc \ @@ -2799,6 +2807,7 @@ tests_testRock_SOURCES = \ tests/stub_access_log.cc \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ + client_db.h \ tests/stub_client_db.cc \ tests/stub_client_side_request.cc \ tests/stub_debug.cc \ @@ -2868,6 +2877,7 @@ tests_testCoss_SOURCES = \ tests/testMain.cc \ tests/testCoss.h \ tests/stub_cache_manager.cc \ + client_db.h \ tests/stub_client_db.cc \ tests/stub_debug.cc \ tests/stub_HelperChildConfig.cc \ @@ -3137,6 +3147,7 @@ tests_testURL_SOURCES = \ carp.cc \ cbdata.cc \ ChunkedCodingParser.cc \ + client_db.h \ client_db.cc \ client_side.cc \ client_side_reply.cc \ diff --git a/src/acl/DestinationDomain.cc b/src/acl/DestinationDomain.cc index db961d09b6..9c2e916ff2 100644 --- a/src/acl/DestinationDomain.cc +++ b/src/acl/DestinationDomain.cc @@ -39,6 +39,7 @@ #include "acl/Checklist.h" #include "acl/RegexData.h" #include "acl/DomainData.h" +#include "fqdncache.h" #include "HttpRequest.h" #include "ipcache.h" #include "protos.h" diff --git a/src/acl/MaxConnection.cc b/src/acl/MaxConnection.cc index 05fc0be9cb..c4b33239ca 100644 --- a/src/acl/MaxConnection.cc +++ b/src/acl/MaxConnection.cc @@ -37,6 +37,7 @@ #include "squid.h" #include "acl/FilledChecklist.h" #include "acl/MaxConnection.h" +#include "client_db.h" #include "Debug.h" #include "protos.h" #include "wordlist.h" diff --git a/src/acl/SourceDomain.cc b/src/acl/SourceDomain.cc index 61ff7fb174..5a0f95e059 100644 --- a/src/acl/SourceDomain.cc +++ b/src/acl/SourceDomain.cc @@ -39,6 +39,7 @@ #include "acl/Checklist.h" #include "acl/RegexData.h" #include "acl/DomainData.h" +#include "fqdncache.h" #include "HttpRequest.h" #include "protos.h" diff --git a/src/client_db.cc b/src/client_db.cc index 362c310aa4..5a92bab76f 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -33,9 +33,11 @@ */ #include "squid.h" +#include "client_db.h" #include "event.h" #include "format/Token.h" #include "ClientInfo.h" +#include "fqdncache.h" #include "ip/Address.h" #include "mgr/Registration.h" #include "protos.h" diff --git a/src/client_db.h b/src/client_db.h new file mode 100644 index 0000000000..dab0b3b6fc --- /dev/null +++ b/src/client_db.h @@ -0,0 +1,57 @@ +/* + * DEBUG: section + * AUTHOR: + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + + +#ifndef SQUID_CLIENT_DB_H_ +#define SQUID_CLIENT_DB_H_ + +#include "anyp/ProtocolType.h" +#include "enums.h" +#include "ip/Address.h" + +class StoreEntry; +class ClientInfo; + +extern void clientdbInit(void); +extern void clientdbUpdate(const Ip::Address &, log_type, AnyP::ProtocolType, size_t); +extern int clientdbCutoffDenied(const Ip::Address &); +extern void clientdbDump(StoreEntry *); +extern void clientdbFreeMemory(void); +extern int clientdbEstablished(const Ip::Address &, int); + +#if USE_DELAY_POOLS +extern void clientdbSetWriteLimiter(ClientInfo * info, const int writeSpeedLimit,const double initialBurst,const double highWatermark); +extern ClientInfo * clientdbGetInfo(const Ip::Address &addr); +#endif + + +#endif /* SQUID_CLIENT_DB_H_ */ diff --git a/src/client_side.cc b/src/client_side.cc index 0e6c8c75b0..656e8d36f2 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -88,6 +88,7 @@ #include "base/Subscription.h" #include "base/TextException.h" #include "ChunkedCodingParser.h" +#include "client_db.h" #include "client_side_reply.h" #include "client_side_request.h" #include "client_side.h" @@ -103,6 +104,7 @@ #include "eui/Config.h" #include "fde.h" #include "forward.h" +#include "fqdncache.h" #include "HttpHdrContRange.h" #include "HttpReply.h" #include "HttpRequest.h" diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index 1ba79a6036..e7c362ea71 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -34,6 +34,7 @@ #include "squid.h" #include "base/TextException.h" +#include "client_db.h" #include "comm/AcceptLimiter.h" #include "CommCalls.h" #include "comm/comm_internal.h" diff --git a/src/format/Format.cc b/src/format/Format.cc index efb187397b..abe8e5749f 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -8,6 +8,7 @@ #include "format/Format.h" #include "format/Quoting.h" #include "format/Token.h" +#include "fqdncache.h" #include "HttpRequest.h" #include "MemBuf.h" #include "protos.h" diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 42e80aca19..a1bf77f31e 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -588,50 +588,6 @@ fqdncache_nbgethostbyaddr(const Ip::Address &addr, FQDNH * handler, void *handle #endif } -/// \ingroup FQDNCacheInternal -static void -fqdncacheRegisterWithCacheManager(void) -{ - Mgr::RegisterAction("fqdncache", "FQDN Cache Stats and Contents", - fqdnStats, 0, 1); - -} - -/** - \ingroup FQDNCacheAPI - * - * Initialize the fqdncache. - * Called after IP cache initialization. - */ -void -fqdncache_init(void) -{ - int n; - - fqdncacheRegisterWithCacheManager(); - - if (fqdn_table) - return; - - debugs(35, 3, "Initializing FQDN Cache..."); - - memset(&FqdncacheStats, '\0', sizeof(FqdncacheStats)); - - memset(&lru_list, '\0', sizeof(lru_list)); - - fqdncache_high = (long) (((float) Config.fqdncache.size * - (float) FQDN_HIGH_WATER) / (float) 100); - - fqdncache_low = (long) (((float) Config.fqdncache.size * - (float) FQDN_LOW_WATER) / (float) 100); - - n = hashPrime(fqdncache_high / 4); - - fqdn_table = hash_create((HASHCMP *) strcmp, n, hash4); - - memDataInit(MEM_FQDNCACHE_ENTRY, "fqdncache_entry", - sizeof(fqdncache_entry), 0); -} /** \ingroup FQDNCacheAPI @@ -746,6 +702,7 @@ fqdnStats(StoreEntry * sentry) } /// \ingroup FQDNCacheAPI +#if 0 const char * fqdnFromAddr(const Ip::Address &addr) { @@ -761,6 +718,7 @@ fqdnFromAddr(const Ip::Address &addr) return buf; } +#endif /// \ingroup FQDNCacheInternal static void @@ -873,6 +831,50 @@ fqdncacheAddEntryFromHosts(char *addr, wordlist * hostnames) fqdncacheLockEntry(fce); } +/// \ingroup FQDNCacheInternal +static void +fqdncacheRegisterWithCacheManager(void) +{ + Mgr::RegisterAction("fqdncache", "FQDN Cache Stats and Contents", + fqdnStats, 0, 1); + +} + +/** + \ingroup FQDNCacheAPI + * + * Initialize the fqdncache. + * Called after IP cache initialization. + */ +void +fqdncache_init(void) +{ + int n; + + fqdncacheRegisterWithCacheManager(); + + if (fqdn_table) + return; + + debugs(35, 3, "Initializing FQDN Cache..."); + + memset(&FqdncacheStats, '\0', sizeof(FqdncacheStats)); + + memset(&lru_list, '\0', sizeof(lru_list)); + + fqdncache_high = (long) (((float) Config.fqdncache.size * + (float) FQDN_HIGH_WATER) / (float) 100); + + fqdncache_low = (long) (((float) Config.fqdncache.size * + (float) FQDN_LOW_WATER) / (float) 100); + + n = hashPrime(fqdncache_high / 4); + + fqdn_table = hash_create((HASHCMP *) strcmp, n, hash4); + + memDataInit(MEM_FQDNCACHE_ENTRY, "fqdncache_entry", + sizeof(fqdncache_entry), 0); +} #if SQUID_SNMP /** diff --git a/src/fqdncache.h b/src/fqdncache.h new file mode 100644 index 0000000000..e6d916c72e --- /dev/null +++ b/src/fqdncache.h @@ -0,0 +1,59 @@ +/* + * DEBUG: section + * AUTHOR: + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + + +#ifndef SQUID_FQDNCACHE_H_ +#define SQUID_FQDNCACHE_H_ + +#include "ip/Address.h" +#include "typedefs.h" + +class StoreEntry; +class wordlist; + +extern void fqdncache_init(void); +void fqdnStats(StoreEntry *); +//extern void fqdncacheReleaseInvalid(const char *); +//extern int fqdncacheQueueDrain(void); +extern void fqdncacheFreeMemory(void); +extern void fqdncache_restart(void); +extern void fqdncache_purgelru(void *); +extern void fqdncacheAddEntryFromHosts(char *addr, wordlist * hostnames); + +extern const char *fqdncache_gethostbyaddr(const Ip::Address &, int flags); +//extern const char *fqdnFromAddr(const Ip::Address &); +extern void fqdncache_nbgethostbyaddr(const Ip::Address &, FQDNH *, void *); + + + + +#endif /* SQUID_FQDNCACHE_H_ */ diff --git a/src/icp_v2.cc b/src/icp_v2.cc index ee6ef69490..6ff79657c2 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -39,6 +39,7 @@ #include "AccessLogEntry.h" #include "acl/Acl.h" #include "acl/FilledChecklist.h" +#include "client_db.h" #include "comm.h" #include "comm/Connection.h" #include "comm/Loops.h" diff --git a/src/log/FormatSquidIcap.cc b/src/log/FormatSquidIcap.cc index 1c8c6086f3..3574fa8180 100644 --- a/src/log/FormatSquidIcap.cc +++ b/src/log/FormatSquidIcap.cc @@ -38,6 +38,7 @@ #include "AccessLogEntry.h" #include "format/Quoting.h" +#include "fqdncache.h" #include "HttpRequest.h" #include "log/File.h" #include "log/Formats.h" diff --git a/src/main.cc b/src/main.cc index 35a2ed257b..1eb9596238 100644 --- a/src/main.cc +++ b/src/main.cc @@ -39,6 +39,7 @@ #include "base/RunnersRegistry.h" #include "base/Subscription.h" #include "base/TextException.h" +#include "client_db.h" #include "comm.h" #include "ConfigParser.h" #include "CpuAffinity.h" @@ -50,7 +51,7 @@ #include "format/Token.h" #include "forward.h" #include "fs/Module.h" -#include "fs/Module.h" +#include "fqdncache.h" #include "htcp.h" #include "HttpReply.h" #include "icmp/IcmpSquid.h" diff --git a/src/protos.h b/src/protos.h index 40e7fb8f13..2512eb57c5 100644 --- a/src/protos.h +++ b/src/protos.h @@ -81,20 +81,7 @@ SQUIDCEXTERN void parse_time_t(time_t * var); /* client_side.c - FD related client side routines */ -SQUIDCEXTERN void clientdbInit(void); - #include "anyp/ProtocolType.h" -SQUIDCEXTERN void clientdbUpdate(const Ip::Address &, log_type, AnyP::ProtocolType, size_t); - -SQUIDCEXTERN int clientdbCutoffDenied(const Ip::Address &); -void clientdbDump(StoreEntry *); -SQUIDCEXTERN void clientdbFreeMemory(void); - -SQUIDCEXTERN int clientdbEstablished(const Ip::Address &, int); -#if USE_DELAY_POOLS -SQUIDCEXTERN void clientdbSetWriteLimiter(ClientInfo * info, const int writeSpeedLimit,const double initialBurst,const double highWatermark); -SQUIDCEXTERN ClientInfo * clientdbGetInfo(const Ip::Address &addr); -#endif SQUIDCEXTERN void clientOpenListenSockets(void); SQUIDCEXTERN void clientHttpConnectionsClose(void); SQUIDCEXTERN void httpRequestFree(void *); @@ -132,20 +119,6 @@ extern void fdDumpOpen(void); extern int fdUsageHigh(void); extern void fdAdjustReserved(void); -SQUIDCEXTERN void fqdncache_nbgethostbyaddr(const Ip::Address &, FQDNH *, void *); - -SQUIDCEXTERN const char *fqdncache_gethostbyaddr(const Ip::Address &, int flags); -SQUIDCEXTERN void fqdncache_init(void); -void fqdnStats(StoreEntry *); -SQUIDCEXTERN void fqdncacheReleaseInvalid(const char *); - -SQUIDCEXTERN const char *fqdnFromAddr(const Ip::Address &); -SQUIDCEXTERN int fqdncacheQueueDrain(void); -SQUIDCEXTERN void fqdncacheFreeMemory(void); -SQUIDCEXTERN void fqdncache_restart(void); -extern void fqdncache_purgelru(void *); -SQUIDCEXTERN void fqdncacheAddEntryFromHosts(char *addr, wordlist * hostnames); - class FwdState; /** diff --git a/src/redirect.cc b/src/redirect.cc index 5751ad4c83..621a8ee0f7 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -40,6 +40,7 @@ #include "client_side_request.h" #include "comm/Connection.h" #include "fde.h" +#include "fqdncache.h" #include "globals.h" #include "HttpRequest.h" #include "helper.h" diff --git a/src/tools.cc b/src/tools.cc index 3bea878a80..25080c00d1 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -35,6 +35,7 @@ #include "squid.h" #include "base/Subscription.h" #include "fde.h" +#include "fqdncache.h" #include "htcp.h" #include "ICP.h" #include "ip/Intercept.h"