From: robertc <> Date: Mon, 21 Aug 2006 06:50:40 +0000 (+0000) Subject: Split out cbdata fully, it now is an optional include and no Init call is needed. X-Git-Tag: SQUID_3_0_PRE5~178 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa839030b1f60ab599cd0021b0511e4c9ee7b0fd;p=thirdparty%2Fsquid.git Split out cbdata fully, it now is an optional include and no Init call is needed. --- diff --git a/include/List.h b/include/List.h index 83c7c22eb0..3418aae3c7 100644 --- a/include/List.h +++ b/include/List.h @@ -1,6 +1,6 @@ /* - * $Id: List.h,v 1.6 2005/05/14 20:00:25 hno Exp $ + * $Id: List.h,v 1.7 2006/08/21 00:50:40 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,6 +34,8 @@ #ifndef SQUID_LIST_H #define SQUID_LIST_H +#include "cbdata.h" + template class List diff --git a/src/ACL.h b/src/ACL.h index 0a28abde74..42d44abcfa 100644 --- a/src/ACL.h +++ b/src/ACL.h @@ -1,6 +1,6 @@ /* - * $Id: ACL.h,v 1.16 2006/04/25 12:00:29 robertc Exp $ + * $Id: ACL.h,v 1.17 2006/08/21 00:50:40 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -36,6 +36,7 @@ #ifndef SQUID_ACL_H #define SQUID_ACL_H #include "Array.h" +#include "cbdata.h" #include "dlink.h" /* FIXME: finish splitting out the dependencies here * - typedefs should not be needed to parse this. diff --git a/src/DiskIO/AIO/AIODiskFile.h b/src/DiskIO/AIO/AIODiskFile.h index b20c5516e2..a8b30ad1bf 100644 --- a/src/DiskIO/AIO/AIODiskFile.h +++ b/src/DiskIO/AIO/AIODiskFile.h @@ -1,6 +1,6 @@ /* - * $Id: AIODiskFile.h,v 1.1 2004/12/20 16:30:38 robertc Exp $ + * $Id: AIODiskFile.h,v 1.2 2006/08/21 00:50:43 robertc Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -36,6 +36,7 @@ #include "DiskIO/DiskFile.h" #include "async_io.h" +#include "cbdata.h" class AIODiskIOStrategy; diff --git a/src/DiskIO/Blocking/BlockingFile.h b/src/DiskIO/Blocking/BlockingFile.h index f26580f101..13f87bca51 100644 --- a/src/DiskIO/Blocking/BlockingFile.h +++ b/src/DiskIO/Blocking/BlockingFile.h @@ -1,6 +1,6 @@ /* - * $Id: BlockingFile.h,v 1.1 2004/12/20 16:30:38 robertc Exp $ + * $Id: BlockingFile.h,v 1.2 2006/08/21 00:50:43 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Robert Collins @@ -36,6 +36,8 @@ #ifndef SQUID_BLOCKINGFILE_H #define SQUID_BLOCKINGFILE_H + +#include "cbdata.h" #include "DiskIO/DiskFile.h" class BlockingFile : public DiskFile diff --git a/src/DiskIO/DiskDaemon/DiskdFile.h b/src/DiskIO/DiskDaemon/DiskdFile.h index d83bbeddd1..f5bcf19b1b 100644 --- a/src/DiskIO/DiskDaemon/DiskdFile.h +++ b/src/DiskIO/DiskDaemon/DiskdFile.h @@ -1,6 +1,6 @@ /* - * $Id: DiskdFile.h,v 1.1 2004/12/20 16:30:38 robertc Exp $ + * $Id: DiskdFile.h,v 1.2 2006/08/21 00:50:45 robertc Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -37,6 +37,7 @@ #ifndef __STORE_DISKDFILE_H__ #define __STORE_DISKDFILE_H__ +#include "cbdata.h" #include "DiskIO/DiskFile.h" class DiskdIOStrategy; diff --git a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h index 23ebb2d0a2..aa7e0d3900 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h +++ b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h @@ -1,6 +1,6 @@ /* - * $Id: DiskThreadsDiskFile.h,v 1.1 2004/12/20 16:30:38 robertc Exp $ + * $Id: DiskThreadsDiskFile.h,v 1.2 2006/08/21 00:50:45 robertc Exp $ * * DEBUG: section 79 Disk IO Routines * AUTHOR: Robert Collins @@ -36,6 +36,7 @@ #ifndef SQUID_DISKTHREADSDISKFILE_H #define SQUID_DISKTHREADSDISKFILE_H +#include "cbdata.h" #include "DiskIO/DiskFile.h" #include "DiskThreads.h" diff --git a/src/DiskIO/ReadRequest.h b/src/DiskIO/ReadRequest.h index b0a7f8d474..66d2c671f0 100644 --- a/src/DiskIO/ReadRequest.h +++ b/src/DiskIO/ReadRequest.h @@ -1,6 +1,6 @@ /* - * $Id: ReadRequest.h,v 1.1 2004/12/20 16:30:38 robertc Exp $ + * $Id: ReadRequest.h,v 1.2 2006/08/21 00:50:43 robertc Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -36,6 +36,7 @@ #include "squid.h" +#include "cbdata.h" #include "RefCount.h" class ReadRequest : public RefCountable diff --git a/src/DiskIO/WriteRequest.h b/src/DiskIO/WriteRequest.h index 52ef989e7d..ce142a010a 100644 --- a/src/DiskIO/WriteRequest.h +++ b/src/DiskIO/WriteRequest.h @@ -1,6 +1,6 @@ /* - * $Id: WriteRequest.h,v 1.1 2004/12/20 16:30:38 robertc Exp $ + * $Id: WriteRequest.h,v 1.2 2006/08/21 00:50:43 robertc Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -36,6 +36,7 @@ #include "squid.h" +#include "cbdata.h" #include "RefCount.h" class WriteRequest : public RefCountable diff --git a/src/ESI.cc b/src/ESI.cc index e994428db8..5eda8b8133 100644 --- a/src/ESI.cc +++ b/src/ESI.cc @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.21 2006/05/06 22:23:44 wessels Exp $ + * $Id: ESI.cc,v 1.22 2006/08/21 00:50:40 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -38,6 +38,7 @@ #include "ESI.h" #include "clientStream.h" #include "client_side_request.h" +#include "errorpage.h" #include "ESISegment.h" #include "ESIElement.h" #include "ESIContext.h" diff --git a/src/ESISegment.h b/src/ESISegment.h index 44da5717e2..b1c48e45e4 100644 --- a/src/ESISegment.h +++ b/src/ESISegment.h @@ -1,5 +1,5 @@ /* - * $Id: ESISegment.h,v 1.3 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESISegment.h,v 1.4 2006/08/21 00:50:40 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -37,6 +37,7 @@ * or perhaps use membuffers here? */ +#include "cbdata.h" #include "RefCount.h" #include "SquidString.h" diff --git a/src/ExternalACLEntry.h b/src/ExternalACLEntry.h index 3e2ce8099f..f99a0faeab 100644 --- a/src/ExternalACLEntry.h +++ b/src/ExternalACLEntry.h @@ -1,6 +1,6 @@ /* - * $Id: ExternalACLEntry.h,v 1.5 2003/08/04 22:14:40 robertc Exp $ + * $Id: ExternalACLEntry.h,v 1.6 2006/08/21 00:50:40 robertc Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -44,6 +44,9 @@ #ifndef SQUID_EXTERNALACLENTRY_H #define SQUID_EXTERNALACLENTRY_H + +#include "cbdata.h" + /****************************************************************** * ExternalACLEntryData * Core data that ExternalACLEntry manages. diff --git a/src/ICAP/ICAPServiceRep.h b/src/ICAP/ICAPServiceRep.h index 62ec6e6964..115f89e24a 100644 --- a/src/ICAP/ICAPServiceRep.h +++ b/src/ICAP/ICAPServiceRep.h @@ -1,6 +1,6 @@ /* - * $Id: ICAPServiceRep.h,v 1.3 2005/12/22 22:26:31 wessels Exp $ + * $Id: ICAPServiceRep.h,v 1.4 2006/08/21 00:50:45 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,6 +34,7 @@ #ifndef SQUID_ICAPSERVICEREP_H #define SQUID_ICAPSERVICEREP_H +#include "cbdata.h" #include "ICAPElements.h" class ICAPOptions; diff --git a/src/ICAP/MsgPipe.h b/src/ICAP/MsgPipe.h index a4938fba5d..7fd5ac8c58 100644 --- a/src/ICAP/MsgPipe.h +++ b/src/ICAP/MsgPipe.h @@ -1,6 +1,6 @@ /* - * $Id: MsgPipe.h,v 1.4 2006/08/07 02:28:24 robertc Exp $ + * $Id: MsgPipe.h,v 1.5 2006/08/21 00:50:45 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,6 +34,7 @@ #ifndef SQUID_MSGPIPE_H #define SQUID_MSGPIPE_H +#include "cbdata.h" #include "event.h" // MsgPipe is a unidirectional communication channel for asynchronously diff --git a/src/Makefile.am b/src/Makefile.am index f561157cd9..5bf02a05de 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.160 2006/08/12 01:43:10 robertc Exp $ +# $Id: Makefile.am,v 1.161 2006/08/21 00:50:41 robertc Exp $ # # Uncomment and customize the following to suit your needs: # @@ -391,6 +391,7 @@ squid_SOURCES = \ CacheManager.h \ carp.cc \ cbdata.cc \ + cbdata.h \ client_db.cc \ client_side.cc \ client_side.h \ @@ -513,11 +514,12 @@ squid_SOURCES = \ redirect.cc \ referer.cc \ refresh.cc \ + RemovalPolicy.cc \ + RemovalPolicy.h \ send-announce.cc \ $(SNMP_SOURCE) \ squid.h \ SquidNew.cc \ - tunnel.cc \ $(SSL_SOURCE) \ stat.cc \ StatHist.cc \ @@ -565,6 +567,7 @@ squid_SOURCES = \ SwapDir.h \ time.cc \ tools.cc \ + tunnel.cc \ typedefs.h \ $(UNLINKDSOURCE) \ url.cc \ @@ -739,6 +742,7 @@ ufsdump_SOURCES = \ $(DNSSOURCE) \ enums.h \ errorpage.cc \ + errorpage.h \ $(ESI_SOURCE) \ ETag.cc \ event.cc \ @@ -799,6 +803,7 @@ ufsdump_SOURCES = \ redirect.cc \ referer.cc \ refresh.cc \ + RemovalPolicy.cc \ send-announce.cc \ $(SNMP_SOURCE) \ squid.h \ @@ -1281,6 +1286,7 @@ tests_testCacheManager_SOURCES = \ redirect.cc \ referer.cc \ refresh.cc \ + RemovalPolicy.cc \ Server.cc \ $(SNMP_SOURCE) \ $(SSL_SOURCE) \ @@ -1348,6 +1354,7 @@ tests_testEvent_SOURCES = \ HttpRequest.cc \ HttpRequestMethod.cc \ mem.cc \ + RemovalPolicy.cc \ String.cc \ tests/testEvent.cc \ tests/testEvent.h \ @@ -1497,6 +1504,7 @@ tests_testEventLoop_SOURCES = \ HttpRequest.cc \ HttpRequestMethod.cc \ mem.cc \ + RemovalPolicy.cc \ String.cc \ tests/testEventLoop.cc \ tests/testEventLoop.h \ @@ -1646,17 +1654,20 @@ tests_testEventLoop_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \ HEADERS_TO_TEST = \ tests/testHeader_ACL.cc \ tests/testHeader_AsyncEngine.cc \ + tests/testHeader_cbdata.cc \ tests/testHeader_CompletionDispatcher.cc \ tests/testHeader_ConfigParser.cc \ tests/testHeader_client_side_request.cc \ tests/testHeader_comm.cc \ tests/testHeader_dlink.cc \ + tests/testHeader_errorpage.cc \ tests/testHeader_event.cc \ tests/testHeader_EventLoop.cc \ tests/testHeader_HttpHeader.cc \ tests/testHeader_HttpHeaderRange.cc \ tests/testHeader_HttpReply.cc \ tests/testHeader_HttpRequestMethod.cc \ + tests/testHeader_RemovalPolicy.cc \ tests/testHeader_SquidTime.cc \ tests/testHeader_Store.cc \ tests/testHeader_StoreEntryStream.cc \ @@ -1753,6 +1764,7 @@ tests_test_http_range_SOURCES = \ redirect.cc \ referer.cc \ refresh.cc \ + RemovalPolicy.cc \ Server.cc \ $(SNMP_SOURCE) \ $(SSL_SOURCE) \ @@ -1902,6 +1914,7 @@ tests_testHttpRequest_SOURCES = \ redirect.cc \ referer.cc \ refresh.cc \ + RemovalPolicy.cc \ Server.cc \ $(SNMP_SOURCE) \ $(SSL_SOURCE) \ @@ -1971,6 +1984,7 @@ STORE_TEST_SOURCES=\ EventLoop.cc \ event.cc \ HttpMsg.cc \ + RemovalPolicy.cc \ store_dir.cc \ store.cc \ HttpRequestMethod.cc \ @@ -2147,6 +2161,7 @@ tests_testURL_SOURCES = \ HttpRequest.cc \ HttpRequestMethod.cc \ mem.cc \ + RemovalPolicy.cc \ String.cc \ tests/testURL.cc \ tests/testURL.h \ diff --git a/src/MemBuf.h b/src/MemBuf.h index e128bdc8cc..6d06ea2ad6 100644 --- a/src/MemBuf.h +++ b/src/MemBuf.h @@ -1,7 +1,7 @@ /* - * $Id: MemBuf.h,v 1.7 2006/04/22 05:29:19 robertc Exp $ + * $Id: MemBuf.h,v 1.8 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -35,6 +35,7 @@ #ifndef SQUID_MEMBUF_H #define SQUID_MEMBUF_H +#include "cbdata.h" #include "Packer.h" /* auto-growing memory-resident buffer with printf interface */ diff --git a/src/MemObject.cc b/src/MemObject.cc index 36e74c8646..1dadcc3108 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.22 2006/02/17 18:10:59 wessels Exp $ + * $Id: MemObject.cc,v 1.23 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -63,6 +63,8 @@ url_checksum(const char *url) #endif +RemovalPolicy * mem_policy = NULL; + size_t MemObject::inUseCount() { diff --git a/src/MemObject.h b/src/MemObject.h index 3a778629f7..899fe447a1 100644 --- a/src/MemObject.h +++ b/src/MemObject.h @@ -1,6 +1,6 @@ /* - * $Id: MemObject.h,v 1.12 2006/05/22 19:58:51 wessels Exp $ + * $Id: MemObject.h,v 1.13 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -38,6 +38,7 @@ #include "StoreIOState.h" #include "stmem.h" #include "CommRead.h" +#include "RemovalPolicy.h" typedef void STMCB (void *data, StoreIOBuffer wroteBuffer); @@ -156,4 +157,7 @@ private: MEMPROXY_CLASS_INLINE(MemObject) +/* global current memory removal policy */ +extern RemovalPolicy *mem_policy; + #endif /* SQUID_MEMOBJECT_H */ diff --git a/src/PeerDigest.h b/src/PeerDigest.h new file mode 100644 index 0000000000..cd85a122ea --- /dev/null +++ b/src/PeerDigest.h @@ -0,0 +1,156 @@ + +/* + * $Id: PeerDigest.h,v 1.1 2006/08/21 00:50:41 robertc Exp $ + * + * + * 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_PEERDIGEST_H +#define SQUID_PEERDIGEST_H + +#include "squid.h" + +#if USE_CACHE_DIGESTS + +#include "cbdata.h" + +struct _Version +{ + short int current; /* current version */ + short int required; /* minimal version that can safely handle current version */ +}; + +/* digest control block; used for transmission and storage */ + +class StoreDigestCBlock +{ + public: + Version ver; + int capacity; + int count; + int del_count; + int mask_size; + unsigned char bits_per_entry; + unsigned char hash_func_count; + short int reserved_short; + int reserved[32 - 6]; +}; + +struct _DigestFetchState +{ + PeerDigest *pd; + StoreEntry *entry; + StoreEntry *old_entry; + store_client *sc; + store_client *old_sc; + HttpRequest *request; + int offset; + int mask_offset; + time_t start_time; + time_t resp_time; + time_t expires; + + struct + { + int msg; + int bytes; + } + + sent, recv; + char buf[SM_PAGE_SIZE]; + ssize_t bufofs; + digest_read_state_t state; +}; + +class PeerDigest +{ + +public: + void *operator new (size_t); + void operator delete(void *); + + struct _peer *peer; /* pointer back to peer structure, argh */ + CacheDigest *cd; /* actual digest structure */ + String host; /* copy of peer->host */ + const char *req_result; /* text status of the last request */ + + struct + { + +unsigned int needed: + 1; /* there were requests for this digest */ + +unsigned int usable: + 1; /* can be used for lookups */ + +unsigned int requested: + 1; /* in process of receiving [fresh] digest */ + } + + flags; + + struct + { + /* all times are absolute unless augmented with _delay */ + time_t initialized; /* creation */ + time_t needed; /* first lookup/use by a peer */ + time_t next_check; /* next scheduled check/refresh event */ + time_t retry_delay; /* delay before re-checking _invalid_ digest */ + time_t requested; /* requested a fresh copy of a digest */ + time_t req_delay; /* last request response time */ + time_t received; /* received the current copy of a digest */ + time_t disabled; /* disabled for good */ + } + + times; + + struct + { + cd_guess_stats guess; + int used_count; + + struct + { + int msgs; + kb_t kbytes; + } + + sent, recv; + } + + stats; + +private: + CBDATA_CLASS(PeerDigest); +}; + +extern const Version CacheDigestVer; +#endif + +#endif /* SQUID_PEERDIGEST_H */ diff --git a/src/PeerSelectState.h b/src/PeerSelectState.h index 9002a0406b..84f162beda 100644 --- a/src/PeerSelectState.h +++ b/src/PeerSelectState.h @@ -1,6 +1,6 @@ /* - * $Id: PeerSelectState.h,v 1.1 2003/10/16 21:40:16 robertc Exp $ + * $Id: PeerSelectState.h,v 1.2 2006/08/21 00:50:41 robertc Exp $ * * AUTHOR: Robert Collins * @@ -36,6 +36,7 @@ #ifndef SQUID_PEERSELECTSTATE_H #define SQUID_PEERSELECTSTATE_H +#include "cbdata.h" #include "PingData.h" class ps_state @@ -76,6 +77,8 @@ public: ping_data ping; ACLChecklist *acl_checklist; +private: + CBDATA_CLASS(ps_state); }; diff --git a/src/RemovalPolicy.cc b/src/RemovalPolicy.cc new file mode 100644 index 0000000000..f3fe3b576c --- /dev/null +++ b/src/RemovalPolicy.cc @@ -0,0 +1,39 @@ + +/* + * $Id: RemovalPolicy.cc,v 1.1 2006/08/21 00:50:41 robertc Exp $ + * + * DEBUG: section ? Common Removal policy + * AUTHOR: Robert Collins + * + * 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. + * + */ + +#include "RemovalPolicy.h" +CBDATA_CLASS_INIT(RemovalPolicy); +CBDATA_CLASS_INIT(RemovalPolicyWalker); +CBDATA_CLASS_INIT(RemovalPurgeWalker); diff --git a/src/RemovalPolicy.h b/src/RemovalPolicy.h new file mode 100644 index 0000000000..7424d95017 --- /dev/null +++ b/src/RemovalPolicy.h @@ -0,0 +1,108 @@ + +/* + * $Id: RemovalPolicy.h,v 1.1 2006/08/21 00:50:41 robertc Exp $ + * + * + * 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. + * + * Copyright (c) 2003, Robert Collins + */ + +#ifndef SQUID_REMOVALPOLICY_H +#define SQUID_REMOVALPOLICY_H + +#include "squid.h" +#include "cbdata.h" + +class RemovalPolicyWalker; +class RemovalPurgeWalker; + +class RemovalPolicySettings +{ + +public: + RemovalPolicySettings() : type(NULL), args(NULL) {}; + + char *type; + wordlist *args; +}; + +class RemovalPolicyNode +{ + +public: + RemovalPolicyNode() : data(NULL) {} + + void *data; +}; + +class RemovalPolicy +{ + public: + const char *_type; + void *_data; + void (*Free) (RemovalPolicy * policy); + void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node); + void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node); + void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node); + void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node); + RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy); + RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan); + void (*Stats) (RemovalPolicy * policy, StoreEntry * entry); + private: + CBDATA_CLASS2(RemovalPolicy); +}; + +class RemovalPolicyWalker +{ + public: + RemovalPolicy *_policy; + void *_data; + const StoreEntry *(*Next) (RemovalPolicyWalker * walker); + void (*Done) (RemovalPolicyWalker * walker); + private: + CBDATA_CLASS2(RemovalPolicyWalker); +}; + +class RemovalPurgeWalker +{ + public: + RemovalPolicy *_policy; + void *_data; + int scanned, max_scan, locked; + StoreEntry *(*Next) (RemovalPurgeWalker * walker); + void (*Done) (RemovalPurgeWalker * walker); + private: + CBDATA_CLASS2(RemovalPurgeWalker); +}; + +extern RemovalPolicy *createRemovalPolicy(RemovalPolicySettings * settings); + +typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args); + + +#endif /* SQUID_REMOVALPOLICY_H */ diff --git a/src/Store.h b/src/Store.h index 247bdd1605..008ad74aff 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.24 2006/05/29 00:15:01 robertc Exp $ + * $Id: Store.h,v 1.25 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,6 +43,7 @@ #include "RefCount.h" #include "CommRead.h" #include "Packer.h" +#include "RemovalPolicy.h" #if ESI #include "ESIElement.h" diff --git a/src/StoreIOState.h b/src/StoreIOState.h index 95353a9ba0..2f5f9f1c02 100644 --- a/src/StoreIOState.h +++ b/src/StoreIOState.h @@ -1,6 +1,6 @@ /* - * $Id: StoreIOState.h,v 1.9 2006/05/23 00:30:21 wessels Exp $ + * $Id: StoreIOState.h,v 1.10 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,6 +34,7 @@ #ifndef SQUID_STOREIOSTATE_H #define SQUID_STOREIOSTATE_H +#include "cbdata.h" #include "RefCount.h" class StoreIOState : public RefCountable diff --git a/src/SwapDir.h b/src/SwapDir.h index b667806a4f..c864f25837 100644 --- a/src/SwapDir.h +++ b/src/SwapDir.h @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.10 2006/08/19 12:31:21 robertc Exp $ + * $Id: SwapDir.h,v 1.11 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -37,6 +37,9 @@ #include "Store.h" #include "StoreIOState.h" +/* forward decls */ +class RemovalPolicy; + /* Store dir configuration routines */ /* SwapDir *sd, char *path ( + char *opt later when the strtok mess is gone) */ diff --git a/src/acl_noncore.cc b/src/acl_noncore.cc index 0f492571a2..5bee2d37dd 100644 --- a/src/acl_noncore.cc +++ b/src/acl_noncore.cc @@ -1,5 +1,5 @@ /* - * $Id: acl_noncore.cc,v 1.2 2006/04/25 12:00:29 robertc Exp $ + * $Id: acl_noncore.cc,v 1.3 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -42,6 +42,7 @@ #include "ACL.h" #include "ACLChecklist.h" #include "ConfigParser.h" +#include "errorpage.h" #include "HttpRequest.h" diff --git a/src/auth/basic/auth_basic.h b/src/auth/basic/auth_basic.h index 6dff777b01..473424f329 100644 --- a/src/auth/basic/auth_basic.h +++ b/src/auth/basic/auth_basic.h @@ -9,6 +9,7 @@ #include "AuthUser.h" #include "AuthUserRequest.h" #include "AuthConfig.h" +#include "helper.h" #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ diff --git a/src/auth/digest/auth_digest.h b/src/auth/digest/auth_digest.h index 4cd6d059db..8891502ed7 100644 --- a/src/auth/digest/auth_digest.h +++ b/src/auth/digest/auth_digest.h @@ -10,6 +10,8 @@ #include "AuthUser.h" #include "AuthUserRequest.h" #include "AuthConfig.h" +#include "helper.h" + /* Generic */ class DigestAuthenticateStateData diff --git a/src/auth/negotiate/auth_negotiate.h b/src/auth/negotiate/auth_negotiate.h index e02ab1a82c..538608627f 100644 --- a/src/auth/negotiate/auth_negotiate.h +++ b/src/auth/negotiate/auth_negotiate.h @@ -9,6 +9,7 @@ #include "AuthUser.h" #include "AuthUserRequest.h" #include "AuthConfig.h" +#include "helper.h" #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ diff --git a/src/auth/ntlm/auth_ntlm.h b/src/auth/ntlm/auth_ntlm.h index 332cc5b04b..fde75ee622 100644 --- a/src/auth/ntlm/auth_ntlm.h +++ b/src/auth/ntlm/auth_ntlm.h @@ -9,6 +9,7 @@ #include "AuthUser.h" #include "AuthUserRequest.h" #include "AuthConfig.h" +#include "helper.h" #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ diff --git a/src/cache_manager.cc b/src/cache_manager.cc index 6ca762ff15..37d734b23c 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.cc,v 1.43 2006/05/29 00:15:01 robertc Exp $ + * $Id: cache_manager.cc,v 1.44 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "CacheManager.h" +#include "errorpage.h" #include "HttpReply.h" #include "HttpRequest.h" #include "Store.h" diff --git a/src/cbdata.cc b/src/cbdata.cc index 91b7cc6a59..ea9ddd70de 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $Id: cbdata.cc,v 1.71 2006/05/29 00:15:01 robertc Exp $ + * $Id: cbdata.cc,v 1.72 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 45 Callback Data Registry * ORIGINAL AUTHOR: Duane Wessels @@ -45,7 +45,7 @@ * when finished. */ -#include "squid.h" +#include "cbdata.h" #include "CacheManager.h" #include "Store.h" #if CBDATA_DEBUG @@ -53,9 +53,6 @@ #endif #include "Generic.h" -/* XXX Remove me */ -#include "PeerSelectState.h" - static int cbdataCount = 0; #if CBDATA_DEBUG dlink_list cbdataEntries; @@ -186,16 +183,11 @@ static void cbdataInternalInitType(cbdata_type type, const char *name, int size, FREE * free_func) { char *label; + assert (type == cbdata_types + 1); - if (type >= cbdata_types) { - cbdata_index = (CBDataIndex *)xrealloc(cbdata_index, (type + 1) * sizeof(*cbdata_index)); - memset(&cbdata_index[cbdata_types], 0, - (type + 1 - cbdata_types) * sizeof(*cbdata_index)); - cbdata_types = type + 1; - } - - if (cbdata_index[type].pool) - return; + cbdata_index = (CBDataIndex *)xrealloc(cbdata_index, (type + 1) * sizeof(*cbdata_index)); + memset(&cbdata_index[type], 0, sizeof(*cbdata_index)); + cbdata_types = type; label = (char *)xmalloc(strlen(name) + 20); @@ -214,34 +206,13 @@ cbdataInternalAddType(cbdata_type type, const char *name, int size, FREE * free_ if (type) return type; - type = (cbdata_type)cbdata_types; + type = (cbdata_type)(cbdata_types + 1); cbdataInternalInitType(type, name, size, free_func); return type; } -void -cbdataInit(void) -{ - debug(45, 3) ("cbdataInit\n"); -#define CREATE_CBDATA(type) cbdataInternalInitType(CBDATA_##type, #type, sizeof(type), NULL) -#define CREATE_CBDATA_FREE(type, free_func) cbdataInternalInitType(CBDATA_##type, #type, sizeof(type), free_func) - /* XXX - * most of these should be moved out to their respective module. - */ - CREATE_CBDATA(ErrorState); - CREATE_CBDATA(generic_cbdata); - CREATE_CBDATA(helper); - CREATE_CBDATA(helper_server); - CREATE_CBDATA(statefulhelper); - CREATE_CBDATA(helper_stateful_server); - CREATE_CBDATA(ps_state); - CREATE_CBDATA(RemovalPolicy); - CREATE_CBDATA(RemovalPolicyWalker); - CREATE_CBDATA(RemovalPurgeWalker); -} - void cbdataRegisterWithCacheManager(CacheManager & manager) { @@ -264,9 +235,11 @@ cbdataInternalAlloc(cbdata_type type) #endif { cbdata *p; - assert(type > 0 && type < cbdata_types); + assert(type > 0 && type <= cbdata_types); + /* placement new: the pool alloc gives us cbdata + user type memory space + * and we init it with cbdata at the start of it + */ p = new (cbdata_index[type].pool->alloc()) cbdata; - // p = (cbdata *)cbdata_index[type].pool->alloc(); p->type = type; p->valid = 1; @@ -337,6 +310,7 @@ cbdataInternalFree(void *p) * we could use the normal delete operator * and it would Just Work. RBC 20030902 */ + assert ( cbdata_index[theType].pool ); cbdata_index[theType].pool->free(c); return NULL; } @@ -535,6 +509,8 @@ cbdataDump(StoreEntry * sentry) storeAppendPrintf(sentry, "\nsee also \"Memory utilization\" for detailed per type statistics\n"); } +CBDATA_CLASS_INIT(generic_cbdata); + #if CBDATA_DEBUG struct CBDataCallDumper : public unary_function diff --git a/src/cbdata.h b/src/cbdata.h new file mode 100644 index 0000000000..1d6ab14810 --- /dev/null +++ b/src/cbdata.h @@ -0,0 +1,139 @@ + +/* + * $Id: cbdata.h,v 1.1 2006/08/21 00:50:41 robertc Exp $ + * + * + * 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. + * + * Copyright (c) 2003, Robert Collins + */ + +#ifndef SQUID_CBDATA_H +#define SQUID_CBDATA_H + +#include "squid.h" + +/* + * cbdata types. similar to the MEM_* types above, but managed + * in cbdata.c. A big difference is that these types are dynamically + * allocated. This list is only a list of predefined types. Other types + * are added runtime + */ +typedef enum { + CBDATA_UNKNOWN = 0, +} cbdata_type; + +extern void cbdataRegisterWithCacheManager(CacheManager & manager); +#if CBDATA_DEBUG +extern void *cbdataInternalAllocDbg(cbdata_type type, const char *, int); +extern void *cbdataInternalFreeDbg(void *p, const char *, int); +extern void cbdataInternalLockDbg(const void *p, const char *, int); +extern void cbdataInternalUnlockDbg(const void *p, const char *, int); +extern int cbdataInternalReferenceDoneValidDbg(void **p, void **tp, const char *, int); +#else +extern void *cbdataInternalAlloc(cbdata_type type); +extern void *cbdataInternalFree(void *p); +extern void cbdataInternalLock(const void *p); +extern void cbdataInternalUnlock(const void *p); +extern int cbdataInternalReferenceDoneValid(void **p, void **tp); +#endif +extern int cbdataReferenceValid(const void *p); +extern cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, FREE * free_func); + + +/* cbdata macros */ +#if CBDATA_DEBUG +#define cbdataAlloc(type) ((type *)cbdataInternalAllocDbg(CBDATA_##type,__FILE__,__LINE__)) +#define cbdataFree(var) do {if (var) {cbdataInternalFreeDbg(var,__FILE__,__LINE__); var = NULL;}} while(0) +#define cbdataInternalLock(a) cbdataInternalLockDbg(a,__FILE__,__LINE__) +#define cbdataInternalUnlock(a) cbdataInternalUnlockDbg(a,__FILE__,__LINE__) +#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValidDbg((void **)&(var), (ptr), __FILE__,__LINE__) +#define CBDATA_CLASS2(type) \ + static cbdata_type CBDATA_##type; \ + public: \ + void *operator new(size_t size) { \ + assert(size == sizeof(type)); \ + (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL))); \ + return cbdataInternalAllocDbg(CBDATA_##type,__FILE__,__LINE__); \ + } \ + void operator delete (void *address) { \ + if (address) cbdataInternalFreeDbg(address,__FILE__,__LINE__); \ + } \ + private: +#else +#define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type)) +#define cbdataFree(var) do {if (var) {cbdataInternalFree(var); var = NULL;}} while(0) +#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr)) +#define CBDATA_CLASS2(type) \ + static cbdata_type CBDATA_##type; \ + public: \ + void *operator new(size_t size) { \ + assert(size == sizeof(type)); \ + (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL))); \ + return (type *)cbdataInternalAlloc(CBDATA_##type); \ + } \ + void operator delete (void *address) { \ + if (address) cbdataInternalFree(address);\ + } \ + private: +#endif +#define cbdataReference(var) (cbdataInternalLock(var), var) +#define cbdataReferenceDone(var) do {if (var) {cbdataInternalUnlock(var); var = NULL;}} while(0) +#define CBDATA_CLASS(type) static cbdata_type CBDATA_##type +#define CBDATA_CLASS_INIT(type) cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN +#define CBDATA_TYPE(type) static cbdata_type CBDATA_##type = CBDATA_UNKNOWN +#define CBDATA_GLOBAL_TYPE(type) cbdata_type CBDATA_##type +#define CBDATA_INIT_TYPE(type) (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL))) +#define CBDATA_INIT_TYPE_FREECB(type, free_func) (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), free_func))) + +/* + * use this when you need to pass callback data to a blocking + * operation, but you don't want to/cannot have that pointer be cbdata itself. + */ + +class generic_cbdata +{ + public: + generic_cbdata(void * data) : data(data) {} + templatevoid unwrap(wrapped_type **output) + { + *output = static_cast(data); + delete this; + } + /* the wrapped data - only public to allow the mild abuse of this facility + * done by store_swapout - it gives a wrapped StoreEntry to StoreIO as the + * object to be given to the callbacks. That needs to be fully cleaned up! + * - RBC 20060820 + */ + void *data; /* the wrapped data */ + private: + CBDATA_CLASS2(generic_cbdata); +}; + + + +#endif /* SQUID_CBDATA_H */ diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index be8673133f..78a2be24b2 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.110 2006/07/02 10:02:04 serassio Exp $ + * $Id: client_side_reply.cc,v 1.111 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -35,6 +35,7 @@ #include "squid.h" #include "client_side_reply.h" +#include "errorpage.h" #include "StoreClient.h" #include "Store.h" #include "HttpReply.h" diff --git a/src/client_side_reply.h b/src/client_side_reply.h index daf3d206dc..794068aba2 100644 --- a/src/client_side_reply.h +++ b/src/client_side_reply.h @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.h,v 1.14 2006/06/07 22:39:34 hno Exp $ + * $Id: client_side_reply.h,v 1.15 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -41,6 +41,9 @@ #include "StoreClient.h" #include "client_side_request.h" + +class ErrorState; + /* XXX make static method */ class clientReplyContext : public RefCountable, public StoreClient diff --git a/src/defines.h b/src/defines.h index 015b4c33f6..1631f39d1f 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.120 2006/08/20 09:50:05 serassio Exp $ + * $Id: defines.h,v 1.121 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -271,51 +271,6 @@ #endif #endif -/* cbdata macros */ -#if CBDATA_DEBUG -#define cbdataAlloc(type) ((type *)cbdataInternalAllocDbg(CBDATA_##type,__FILE__,__LINE__)) -#define cbdataFree(var) do {if (var) {cbdataInternalFreeDbg(var,__FILE__,__LINE__); var = NULL;}} while(0) -#define cbdataInternalLock(a) cbdataInternalLockDbg(a,__FILE__,__LINE__) -#define cbdataInternalUnlock(a) cbdataInternalUnlockDbg(a,__FILE__,__LINE__) -#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValidDbg((void **)&(var), (ptr), __FILE__,__LINE__) -#define CBDATA_CLASS2(type) \ - static cbdata_type CBDATA_##type; \ - public: \ - void *operator new(size_t size) { \ - assert(size == sizeof(type)); \ - (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL))); \ - return cbdataInternalAllocDbg(CBDATA_##type,__FILE__,__LINE__); \ - } \ - void operator delete (void *address) { \ - if (address) cbdataInternalFreeDbg(address,__FILE__,__LINE__); \ - } \ - private: -#else -#define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type)) -#define cbdataFree(var) do {if (var) {cbdataInternalFree(var); var = NULL;}} while(0) -#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr)) -#define CBDATA_CLASS2(type) \ - static cbdata_type CBDATA_##type; \ - public: \ - void *operator new(size_t size) { \ - assert(size == sizeof(type)); \ - (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL))); \ - return (type *)cbdataInternalAlloc(CBDATA_##type); \ - } \ - void operator delete (void *address) { \ - if (address) cbdataInternalFree(address);\ - } \ - private: -#endif -#define cbdataReference(var) (cbdataInternalLock(var), var) -#define cbdataReferenceDone(var) do {if (var) {cbdataInternalUnlock(var); var = NULL;}} while(0) -#define CBDATA_CLASS(type) static cbdata_type CBDATA_##type -#define CBDATA_CLASS_INIT(type) cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN -#define CBDATA_TYPE(type) static cbdata_type CBDATA_##type = CBDATA_UNKNOWN -#define CBDATA_GLOBAL_TYPE(type) cbdata_type CBDATA_##type -#define CBDATA_INIT_TYPE(type) (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL))) -#define CBDATA_INIT_TYPE_FREECB(type, free_func) (CBDATA_##type ? CBDATA_UNKNOWN : (CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), free_func))) - #ifndef O_TEXT #define O_TEXT 0 #endif diff --git a/src/enums.h b/src/enums.h index a3c2eba08b..e052646e3e 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.253 2006/08/07 02:28:22 robertc Exp $ + * $Id: enums.h,v 1.254 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -495,31 +495,6 @@ enum { NETDB_EX_HOPS }; -/* - * cbdata types. similar to the MEM_* types above, but managed - * in cbdata.c. A big difference is that these types are dynamically - * allocated. This list is only a list of predefined types. Other types - * are added runtime - */ -typedef enum { - CBDATA_UNKNOWN = 0, - CBDATA_UNDEF = 0, - CBDATA_acl_access, - CBDATA_ConnStateData, - CBDATA_ErrorState, - CBDATA_FwdState, - CBDATA_generic_cbdata, - CBDATA_helper, - CBDATA_helper_server, - CBDATA_statefulhelper, - CBDATA_helper_stateful_server, - CBDATA_ps_state, - CBDATA_RemovalPolicy, - CBDATA_RemovalPolicyWalker, - CBDATA_RemovalPurgeWalker, - CBDATA_FIRST_CUSTOM_TYPE = 1000 -} cbdata_type; - /* * Return codes from checkVary(request) */ diff --git a/src/errorpage.cc b/src/errorpage.cc index 60b45e2f3e..5ec8a0a722 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.214 2006/05/19 17:19:09 wessels Exp $ + * $Id: errorpage.cc,v 1.215 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -40,7 +40,7 @@ * Config.errorDirectory) */ -#include "squid.h" +#include "errorpage.h" #include "AuthUserRequest.h" #include "SquidTime.h" #include "Store.h" @@ -52,6 +52,8 @@ #include "URLScheme.h" #include "wordlist.h" +CBDATA_CLASS_INIT(ErrorState); + /* local types */ typedef struct @@ -322,8 +324,7 @@ errorPageName(int pageId) ErrorState * errorCon(err_type type, http_status status) { - ErrorState *err; - err = cbdataAlloc(ErrorState); + ErrorState *err = new ErrorState; err->page_id = type; /* has to be reset manually if needed */ err->type = type; err->httpStatus = status; diff --git a/src/errorpage.h b/src/errorpage.h new file mode 100644 index 0000000000..6ec68f5b36 --- /dev/null +++ b/src/errorpage.h @@ -0,0 +1,93 @@ + +/* + * $Id: errorpage.h,v 1.1 2006/08/21 00:50:41 robertc Exp $ + * + * + * 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. + * + * Copyright (c) 2003, Robert Collins + */ + +#ifndef SQUID_ERRORPAGE_H +#define SQUID_ERRORPAGE_H + +#include "squid.h" +#include "cbdata.h" + +class ErrorState +{ + public: + err_type type; + int page_id; + http_status httpStatus; + auth_user_request_t *auth_user_request; + HttpRequest *request; + char *url; + int xerrno; + u_short port; + char *dnsserver_msg; + time_t ttl; + + struct IN_ADDR src_addr; + char *redirect_url; + ERCB *callback; + void *callback_data; + + struct + { + +unsigned int flag_cbdata: + 1; + } + + flags; + + struct + { + wordlist *server_msg; + char *request; + char *reply; + } + + ftp; + char *request_hdrs; + char *err_msg; /* Preformatted error message from the cache */ + private: + CBDATA_CLASS2(ErrorState); +}; + +SQUIDCEXTERN void errorInitialize(void); +SQUIDCEXTERN void errorClean(void); +SQUIDCEXTERN HttpReply *errorBuildReply(ErrorState * err); +SQUIDCEXTERN void errorSend(int fd, ErrorState *); +SQUIDCEXTERN void errorAppendEntry(StoreEntry *, ErrorState *); +SQUIDCEXTERN void errorStateFree(ErrorState * err); +SQUIDCEXTERN err_type errorReservePageId(const char *page_name); +SQUIDCEXTERN ErrorState *errorCon(err_type type, http_status); + + +#endif /* SQUID_ERRORPAGE_H */ diff --git a/src/event.cc b/src/event.cc index 74ee38322f..d6fccd7694 100644 --- a/src/event.cc +++ b/src/event.cc @@ -1,6 +1,6 @@ /* - * $Id: event.cc,v 1.42 2006/08/12 01:43:11 robertc Exp $ + * $Id: event.cc,v 1.43 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 41 Event Processing * AUTHOR: Henrik Nordstrom @@ -183,7 +183,7 @@ int EventScheduler::checkDelay() { if (!tasks) - return (int) 10; + return EVENT_IDLE; int result = (int) ((tasks->when - current_dtime) * 1000); diff --git a/src/external_acl.cc b/src/external_acl.cc index 76e289bf15..45124d3c13 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -1,6 +1,6 @@ /* - * $Id: external_acl.cc,v 1.73 2006/05/29 00:15:02 robertc Exp $ + * $Id: external_acl.cc,v 1.74 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -56,6 +56,7 @@ #include "client_side.h" #include "HttpRequest.h" #include "authenticate.h" +#include "helper.h" #include "MemBuf.h" #include "URLScheme.h" #include "wordlist.h" diff --git a/src/forward.cc b/src/forward.cc index fac0684f6d..da946a40ee 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.147 2006/08/07 02:28:22 robertc Exp $ + * $Id: forward.cc,v 1.148 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -35,18 +35,19 @@ #include "squid.h" -#include "event.h" -#include "CacheManager.h" #include "forward.h" -#include "SquidTime.h" -#include "Store.h" -#include "HttpRequest.h" -#include "fde.h" -#include "MemObject.h" #include "ACLChecklist.h" #include "ACL.h" +#include "CacheManager.h" +#include "event.h" +#include "errorpage.h" +#include "fde.h" #include "HttpReply.h" +#include "HttpRequest.h" +#include "MemObject.h" #include "pconn.h" +#include "SquidTime.h" +#include "Store.h" static PSC fwdStartCompleteWrapper; static PF fwdServerClosedWrapper; diff --git a/src/forward.h b/src/forward.h index 9cf06cc65d..9c2f416fbb 100644 --- a/src/forward.h +++ b/src/forward.h @@ -4,6 +4,7 @@ /* forward decls */ class CacheManager; +class ErrorState; #include "comm.h" diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 19862cf89e..617ddff14a 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.169 2006/08/07 02:28:22 robertc Exp $ + * $Id: fqdncache.cc,v 1.170 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "cbdata.h" #include "event.h" #include "CacheManager.h" #include "SquidTime.h" @@ -411,6 +412,7 @@ fqdncacheParse(fqdncache_entry *f, rfc1035_rr * answers, int nr, const char *err #endif + static void #if USE_DNSSERVERS fqdncacheHandleReply(void *data, char *reply) @@ -419,10 +421,8 @@ fqdncacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error #endif { int n; - generic_cbdata *c = (generic_cbdata *)data; - fqdncache_entry *f = (fqdncache_entry *)c->data; - cbdataFree(c); - c = NULL; + fqdncache_entry *f; + static_cast(data)->unwrap(&f); n = ++FqdncacheStats.replies; statHistCount(&statCounter.dns.svc_time, tvSubMsec(f->request_time, current_time)); @@ -495,8 +495,7 @@ fqdncache_nbgethostbyaddr(struct IN_ADDR addr, FQDNH * handler, void *handlerDat f->handler = handler; f->handlerData = cbdataReference(handlerData); f->request_time = current_time; - c = cbdataAlloc(generic_cbdata); - c->data = f; + c = new generic_cbdata(f); #if USE_DNSSERVERS dnsSubmit(hashKeyStr(&f->hash), fqdncacheHandleReply, c); diff --git a/src/ftp.cc b/src/ftp.cc index 5783c9f558..1050b76d93 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.399 2006/06/14 19:43:28 serassio Exp $ + * $Id: ftp.cc,v 1.400 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -37,6 +37,7 @@ #include "Store.h" #include "HttpRequest.h" #include "HttpReply.h" +#include "errorpage.h" #include "fde.h" #include "comm.h" #include "HttpHeaderRange.h" diff --git a/src/globals.h b/src/globals.h index 29b9ea8b7d..f8b0da85d2 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.137 2006/08/19 12:31:21 robertc Exp $ + * $Id: globals.h,v 1.138 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -144,10 +144,6 @@ extern "C" extern CacheDigest *store_digest; /* NULL */ extern const char *StoreDigestFileName; /* "store_digest" */ extern const char *StoreDigestMimeStr; /* "application/cache-digest" */ -#if USE_CACHE_DIGESTS - - extern const Version CacheDigestVer; /* { 5, 3 } */ -#endif extern const char *MultipartMsgBoundaryStr; /* "Unique-Squid-Separator" */ #if HTTP_VIOLATIONS @@ -161,7 +157,6 @@ extern "C" extern int store_swap_high; /* 0 */ extern size_t store_pages_max; /* 0 */ extern ssize_t store_maxobjsize; /* -1 */ - extern RemovalPolicy *mem_policy; extern hash_table *proxy_auth_username_cache; /* NULL */ extern int incoming_sockets_accepted; #ifdef _SQUID_MSWIN_ diff --git a/src/gopher.cc b/src/gopher.cc index b01789b60d..f35fcc3ca8 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.197 2006/05/19 17:19:09 wessels Exp $ + * $Id: gopher.cc,v 1.198 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "errorpage.h" #include "Store.h" #include "HttpRequest.h" #include "comm.h" diff --git a/src/helper.cc b/src/helper.cc index b34e13fc9e..352c422b82 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -1,6 +1,6 @@ /* - * $Id: helper.cc,v 1.74 2006/05/08 23:38:33 robertc Exp $ + * $Id: helper.cc,v 1.75 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Harvest Derived? @@ -63,6 +63,11 @@ static helper_stateful_request *StatefulServerDequeue(helper_stateful_server * s static void StatefulServerEnqueue(helper_stateful_server * srv, helper_stateful_request * r); static void helperStatefulServerKickQueue(helper_stateful_server * srv); +CBDATA_TYPE(helper); +CBDATA_TYPE(helper_server); +CBDATA_TYPE(statefulhelper); +CBDATA_TYPE(helper_stateful_server); + void helperOpenServers(helper * hlp) { @@ -123,6 +128,7 @@ helperOpenServers(helper * hlp) hlp->n_running++; hlp->n_active++; + CBDATA_INIT_TYPE(helper_server); srv = cbdataAlloc(helper_server); srv->pid = x; srv->index = k; @@ -221,6 +227,7 @@ helperStatefulOpenServers(statefulhelper * hlp) hlp->n_running++; hlp->n_active++; + CBDATA_INIT_TYPE(helper_stateful_server); srv = cbdataAlloc(helper_stateful_server); srv->pid = x; srv->flags.reserved = S_HELPER_FREE; @@ -706,6 +713,7 @@ helper * helperCreate(const char *name) { helper *hlp; + CBDATA_INIT_TYPE(helper); hlp = cbdataAlloc(helper); hlp->id_name = name; return hlp; @@ -715,6 +723,7 @@ statefulhelper * helperStatefulCreate(const char *name) { statefulhelper *hlp; + CBDATA_INIT_TYPE(statefulhelper); hlp = cbdataAlloc(statefulhelper); hlp->id_name = name; return hlp; diff --git a/src/helper.h b/src/helper.h index 8c28682f05..0bdb5d9222 100644 --- a/src/helper.h +++ b/src/helper.h @@ -1,6 +1,6 @@ /* - * $Id: helper.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ + * $Id: helper.h,v 1.4 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Harvest Derived? @@ -37,6 +37,172 @@ #define SQUID_HELPER_H #include "squid.h" +#include "cbdata.h" + +class helper_request; + +typedef struct _helper helper; + +typedef struct _helper_stateful statefulhelper; + +typedef struct _helper_server helper_server; + +typedef struct _helper_stateful_server helper_stateful_server; + +typedef struct _helper_flags helper_flags; + +typedef struct _helper_stateful_flags helper_stateful_flags; + +typedef stateful_helper_callback_t HLPSCB(void *, void *lastserver, char *buf); + +struct _helper +{ + wordlist *cmdline; + dlink_list servers; + dlink_list queue; + const char *id_name; + int n_to_start; + int n_running; + int n_active; + int ipc_type; + unsigned int concurrency; + time_t last_queue_warn; + time_t last_restart; + + struct + { + int requests; + int replies; + int queue_size; + int avg_svc_time; + } + + stats; +}; + +struct _helper_stateful +{ + wordlist *cmdline; + dlink_list servers; + dlink_list queue; + const char *id_name; + int n_to_start; + int n_running; + int n_active; + int ipc_type; + MemAllocatorProxy *datapool; + HLPSAVAIL *IsAvailable; + HLPSONEQ *OnEmptyQueue; + time_t last_queue_warn; + time_t last_restart; + + struct + { + int requests; + int replies; + int queue_size; + int avg_svc_time; + } + + stats; +}; + +struct _helper_server +{ + int index; + int pid; + int rfd; + int wfd; + MemBuf *wqueue; + MemBuf *writebuf; + char *rbuf; + size_t rbuf_sz; + off_t roffset; + + struct timeval dispatch_time; + + struct timeval answer_time; + + dlink_node link; + helper *parent; + helper_request **requests; + + struct _helper_flags + { + +unsigned int writing: + 1; + +unsigned int closing: + 1; + +unsigned int shutdown: + 1; + } + + flags; + + struct + { + int uses; + unsigned int pending; + } + + stats; +}; + +class helper_stateful_request; + +struct _helper_stateful_server +{ + int index; + int pid; + int rfd; + int wfd; + /* MemBuf wqueue; */ + /* MemBuf writebuf; */ + char *rbuf; + size_t rbuf_sz; + off_t roffset; + + struct timeval dispatch_time; + + struct timeval answer_time; + + dlink_node link; + dlink_list queue; + statefulhelper *parent; + helper_stateful_request *request; + + struct _helper_stateful_flags + { + +unsigned int busy: + 1; + +unsigned int closing: + 1; + +unsigned int shutdown: + 1; + stateful_helper_reserve_t reserved; + } + + flags; + + struct + { + int uses; + int submits; + int releases; + int deferbyfunc; + int deferbycb; + } + + stats; + int deferred_requests; /* current number of deferred requests */ + void *data; /* State data used by the calling routines */ +}; class helper_request { @@ -65,4 +231,24 @@ public: MEMPROXY_CLASS_INLINE(helper_stateful_request) +/* helper.c */ +SQUIDCEXTERN void helperOpenServers(helper * hlp); +SQUIDCEXTERN void helperStatefulOpenServers(statefulhelper * hlp); +SQUIDCEXTERN void helperSubmit(helper * hlp, const char *buf, HLPCB * callback, void *data); +SQUIDCEXTERN void helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, void *data, helper_stateful_server * lastserver); +SQUIDCEXTERN void helperStats(StoreEntry * sentry, helper * hlp); +SQUIDCEXTERN void helperStatefulStats(StoreEntry * sentry, statefulhelper * hlp); +SQUIDCEXTERN void helperShutdown(helper * hlp); +SQUIDCEXTERN void helperStatefulShutdown(statefulhelper * hlp); +SQUIDCEXTERN helper *helperCreate(const char *); +SQUIDCEXTERN statefulhelper *helperStatefulCreate(const char *); +SQUIDCEXTERN void helperFree(helper *); +SQUIDCEXTERN void helperStatefulFree(statefulhelper *); +SQUIDCEXTERN void helperStatefulReset(helper_stateful_server * srv); +SQUIDCEXTERN void helperStatefulReleaseServer(helper_stateful_server * srv); +SQUIDCEXTERN void *helperStatefulServerGetData(helper_stateful_server * srv); +SQUIDCEXTERN helper_stateful_server *helperStatefulDefer(statefulhelper *); + + + #endif /* SQUID_HELPER_H */ diff --git a/src/http.cc b/src/http.cc index a1cd3d831c..beb68e50ef 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.503 2006/06/14 19:39:19 serassio Exp $ + * $Id: http.cc,v 1.504 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -39,6 +39,7 @@ */ #include "squid.h" +#include "errorpage.h" #include "MemBuf.h" #include "http.h" #include "AuthUserRequest.h" diff --git a/src/internal.cc b/src/internal.cc index fbc0ce62d8..563cdfdbe2 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -1,6 +1,6 @@ /* - * $Id: internal.cc,v 1.41 2006/05/12 19:06:10 serassio Exp $ + * $Id: internal.cc,v 1.42 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 76 Internal Squid Object handling * AUTHOR: Duane, Alex, Henrik @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "errorpage.h" #include "Store.h" #include "HttpRequest.h" #include "HttpReply.h" diff --git a/src/ipcache.cc b/src/ipcache.cc index f337033939..7f54344cc9 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.257 2006/08/20 21:02:53 hno Exp $ + * $Id: ipcache.cc,v 1.258 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "cbdata.h" #include "event.h" #include "CacheManager.h" #include "SquidTime.h" @@ -473,10 +474,8 @@ ipcacheHandleReply(void *data, char *reply) ipcacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error_message) #endif { - generic_cbdata *c = (generic_cbdata *)data; - ipcache_entry *i = (ipcache_entry *)c->data; - cbdataFree(c); - c = NULL; + ipcache_entry *i; + static_cast(data)->unwrap(&i); IpcacheStats.replies++; statHistCount(&statCounter.dns.svc_time, tvSubMsec(i->request_time, current_time)); @@ -548,8 +547,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData) i->handler = handler; i->handlerData = cbdataReference(handlerData); i->request_time = current_time; - c = cbdataAlloc(generic_cbdata); - c->data = i; + c = new generic_cbdata(i); #if USE_DNSSERVERS dnsSubmit(hashKeyStr(&i->hash), ipcacheHandleReply, c); diff --git a/src/main.cc b/src/main.cc index 77bd3c201c..23541fb6c6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.431 2006/08/20 09:50:05 serassio Exp $ + * $Id: main.cc,v 1.432 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -38,6 +38,7 @@ #include "authenticate.h" #include "CacheManager.h" #include "ConfigParser.h" +#include "errorpage.h" #include "event.h" #include "EventLoop.h" #include "ExternalACL.h" @@ -1206,8 +1207,6 @@ main(int argc, char **argv) Mem::Init(); - cbdataInit(); - storeFsInit(); /* required for config parsing */ /* May not be needed for parsing, have not audited for such */ diff --git a/src/neighbors.cc b/src/neighbors.cc index 4b90ec4979..77069f916f 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.339 2006/08/07 02:28:22 robertc Exp $ + * $Id: neighbors.cc,v 1.340 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -34,16 +34,17 @@ */ #include "squid.h" +#include "ACLChecklist.h" #include "event.h" #include "CacheManager.h" -#include "Store.h" -#include "ICP.h" +#include "htcp.h" #include "HttpRequest.h" +#include "ICP.h" #include "MemObject.h" -#include "ACLChecklist.h" -#include "htcp.h" +#include "PeerDigest.h" #include "PeerSelectState.h" #include "SquidTime.h" +#include "Store.h" /* count mcast group peers every 15 minutes */ #define MCAST_COUNT_RATE 900 diff --git a/src/net_db.cc b/src/net_db.cc index 794febee33..45caeeb828 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.190 2006/08/07 02:28:22 robertc Exp $ + * $Id: net_db.cc,v 1.191 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -42,6 +42,7 @@ */ #include "squid.h" +#include "cbdata.h" #include "event.h" #include "CacheManager.h" #include "Store.h" @@ -280,12 +281,12 @@ netdbSendPing(const ipcache_addrs * ia, void *data) { struct IN_ADDR addr; - char *hostname = (char *)((generic_cbdata *) data)->data; + char *hostname; + static_cast(data)->unwrap(&hostname); netdbEntry *n; netdbEntry *na; net_db_name *x; net_db_name **X; - cbdataFree(data); if (ia == NULL) { xfree(hostname); @@ -922,17 +923,13 @@ netdbPingSite(const char *hostname) { #if USE_ICMP netdbEntry *n; - generic_cbdata *h; if ((n = netdbLookupHost(hostname)) != NULL) if (n->next_ping_time > squid_curtime) return; - h = cbdataAlloc(generic_cbdata); - - h->data = xstrdup(hostname); - - ipcache_nbgethostbyname(hostname, netdbSendPing, h); + ipcache_nbgethostbyname(hostname, netdbSendPing, + new generic_cbdata(xstrdup(hostname))); #endif } diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 184694222b..c31ad5fe18 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.117 2006/08/07 02:28:22 robertc Exp $ + * $Id: peer_digest.cc,v 1.118 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -37,13 +37,14 @@ #if USE_CACHE_DIGESTS #include "event.h" +#include "forward.h" #include "Store.h" #include "HttpRequest.h" #include "HttpReply.h" #include "MemObject.h" +#include "PeerDigest.h" #include "SquidTime.h" #include "StoreClient.h" -#include "forward.h" /* local types */ @@ -71,6 +72,7 @@ static int peerDigestUseful(const PeerDigest * pd); /* local constants */ +Version const CacheDigestVer = { 5, 3 }; #define StoreDigestCBlockSize sizeof(StoreDigestCBlock) diff --git a/src/peer_select.cc b/src/peer_select.cc index 3bd17444bb..463b2b8543 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.141 2006/08/07 02:28:22 robertc Exp $ + * $Id: peer_select.cc,v 1.142 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -103,6 +103,8 @@ static void peerGetSomeParent(ps_state *); static void peerGetAllParents(ps_state *); static void peerAddFwdServer(FwdServer **, peer *, hier_code); +CBDATA_CLASS_INIT(ps_state); + static void peerSelectStateFree(ps_state * psstate) { @@ -791,6 +793,7 @@ peerAddFwdServer(FwdServer ** FSVR, peer * p, hier_code code) void * ps_state::operator new(size_t) { + CBDATA_INIT_TYPE(ps_state); return cbdataAlloc(ps_state); } diff --git a/src/protos.h b/src/protos.h index 2f61364ec2..0a3ff3f541 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.535 2006/08/07 02:28:22 robertc Exp $ + * $Id: protos.h,v 1.536 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -78,27 +78,6 @@ SQUIDCEXTERN void parse_time_t(time_t * var); SQUIDCEXTERN void parse_sockaddr_in_list_token(sockaddr_in_list **, char *); -/* - * cbdata.c - */ -SQUIDCEXTERN void cbdataInit(void); -SQUIDCEXTERN void cbdataRegisterWithCacheManager(CacheManager & manager); -#if CBDATA_DEBUG -SQUIDCEXTERN void *cbdataInternalAllocDbg(cbdata_type type, const char *, int); -SQUIDCEXTERN void *cbdataInternalFreeDbg(void *p, const char *, int); -SQUIDCEXTERN void cbdataInternalLockDbg(const void *p, const char *, int); -SQUIDCEXTERN void cbdataInternalUnlockDbg(const void *p, const char *, int); -SQUIDCEXTERN int cbdataInternalReferenceDoneValidDbg(void **p, void **tp, const char *, int); -#else -SQUIDCEXTERN void *cbdataInternalAlloc(cbdata_type type); -SQUIDCEXTERN void *cbdataInternalFree(void *p); -SQUIDCEXTERN void cbdataInternalLock(const void *p); -SQUIDCEXTERN void cbdataInternalUnlock(const void *p); -SQUIDCEXTERN int cbdataInternalReferenceDoneValid(void **p, void **tp); -#endif -SQUIDCEXTERN int cbdataReferenceValid(const void *p); -SQUIDCEXTERN cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, FREE * free_func); - /* client_side.c - FD related client side routines */ SQUIDCEXTERN void clientdbInit(void); @@ -675,15 +654,6 @@ SQUIDCEXTERN void logReferer(const char *, const char *, const char *); SQUIDCEXTERN void refererCloseLog(void); SQUIDCEXTERN peer_t parseNeighborType(const char *s); -SQUIDCEXTERN void errorInitialize(void); -SQUIDCEXTERN void errorClean(void); -SQUIDCEXTERN HttpReply *errorBuildReply(ErrorState * err); -SQUIDCEXTERN void errorSend(int fd, ErrorState *); -SQUIDCEXTERN void errorAppendEntry(StoreEntry *, ErrorState *); -SQUIDCEXTERN void errorStateFree(ErrorState * err); -SQUIDCEXTERN err_type errorReservePageId(const char *page_name); -SQUIDCEXTERN ErrorState *errorCon(err_type type, http_status); - /* tools.c */ SQUIDCEXTERN void dlinkAdd(void *data, dlink_node *, dlink_list *); SQUIDCEXTERN void dlinkAddAfter(void *, dlink_node *, dlink_node *, dlink_list *); @@ -746,25 +716,6 @@ extern void carpRegisterWithCacheManager(CacheManager & manager); SQUIDCEXTERN peer *carpSelectParent(HttpRequest *); #endif -/* helper.c */ -SQUIDCEXTERN void helperOpenServers(helper * hlp); -SQUIDCEXTERN void helperStatefulOpenServers(statefulhelper * hlp); -SQUIDCEXTERN void helperSubmit(helper * hlp, const char *buf, HLPCB * callback, void *data); -SQUIDCEXTERN void helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, void *data, helper_stateful_server * lastserver); -SQUIDCEXTERN void helperStats(StoreEntry * sentry, helper * hlp); -SQUIDCEXTERN void helperStatefulStats(StoreEntry * sentry, statefulhelper * hlp); -SQUIDCEXTERN void helperShutdown(helper * hlp); -SQUIDCEXTERN void helperStatefulShutdown(statefulhelper * hlp); -SQUIDCEXTERN helper *helperCreate(const char *); -SQUIDCEXTERN statefulhelper *helperStatefulCreate(const char *); -SQUIDCEXTERN void helperFree(helper *); -SQUIDCEXTERN void helperStatefulFree(statefulhelper *); -SQUIDCEXTERN void helperStatefulReset(helper_stateful_server * srv); -SQUIDCEXTERN void helperStatefulReleaseServer(helper_stateful_server * srv); -SQUIDCEXTERN void *helperStatefulServerGetData(helper_stateful_server * srv); -SQUIDCEXTERN helper_stateful_server *helperStatefulDefer(statefulhelper *); - - #if USE_LEAKFINDER SQUIDCEXTERN void leakInit(void); @@ -786,11 +737,6 @@ logfilePrintf(Logfile * lf, const char *fmt,...) PRINTF_FORMAT_ARG2; SQUIDCEXTERN void logfilePrintf(va_alist); #endif -/* - * Removal Policies - */ -SQUIDCEXTERN RemovalPolicy *createRemovalPolicy(RemovalPolicySettings * settings); - /* * prototypes for system functions missing from system includes */ diff --git a/src/redirect.cc b/src/redirect.cc index e3398de9ea..5c2d6f495c 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.114 2006/07/08 16:38:47 serassio Exp $ + * $Id: redirect.cc,v 1.115 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 61 Redirector * AUTHOR: Duane Wessels @@ -42,6 +42,7 @@ #include "ACLChecklist.h" #include "HttpRequest.h" #include "client_side.h" +#include "helper.h" typedef struct { diff --git a/src/repl/heap/store_repl_heap.cc b/src/repl/heap/store_repl_heap.cc index 40a452a611..5e8351bca2 100644 --- a/src/repl/heap/store_repl_heap.cc +++ b/src/repl/heap/store_repl_heap.cc @@ -1,6 +1,6 @@ /* - * $Id: store_repl_heap.cc,v 1.20 2006/05/19 17:19:10 wessels Exp $ + * $Id: store_repl_heap.cc,v 1.21 2006/08/21 00:50:47 robertc Exp $ * * DEBUG: section ? HEAP based removal policies * AUTHOR: Henrik Nordstrom @@ -184,7 +184,7 @@ heap_walkDone(RemovalPolicyWalker * walker) assert(heap->nwalkers > 0); heap->nwalkers -= 1; safe_free(walker->_data); - cbdataFree(walker); + delete walker; } static RemovalPolicyWalker * @@ -194,7 +194,7 @@ heap_walkInit(RemovalPolicy * policy) RemovalPolicyWalker *walker; HeapWalkData *heap_walk; heap->nwalkers += 1; - walker = cbdataAlloc(RemovalPolicyWalker); + walker = new RemovalPolicyWalker; heap_walk = (HeapWalkData *)xcalloc(1, sizeof(*heap_walk)); heap_walk->current = 0; walker->_policy = policy; @@ -274,7 +274,7 @@ heap_purgeDone(RemovalPurgeWalker * walker) } safe_free(walker->_data); - cbdataFree(walker); + delete walker; } static RemovalPurgeWalker * @@ -284,7 +284,7 @@ heap_purgeInit(RemovalPolicy * policy, int max_scan) RemovalPurgeWalker *walker; HeapPurgeData *heap_walk; heap->nwalkers += 1; - walker = cbdataAlloc(RemovalPurgeWalker); + walker = new RemovalPurgeWalker; heap_walk = (HeapPurgeData *)xcalloc(1, sizeof(*heap_walk)); heap_walk->min_age = 0.0; heap_walk->locked_entries = NULL; @@ -307,7 +307,7 @@ heap_free(RemovalPolicy * policy) /* Ok, time to destroy this policy */ safe_free(heap); memset(policy, 0, sizeof(*policy)); - cbdataFree(policy); + delete policy; } RemovalPolicy * @@ -317,7 +317,7 @@ createRemovalPolicy_heap(wordlist * args) HeapPolicyData *heap_data; const char *keytype; /* Allocate the needed structures */ - policy = cbdataAlloc(RemovalPolicy); + policy = new RemovalPolicy; heap_data = (HeapPolicyData *)xcalloc(1, sizeof(*heap_data)); /* Initialize the policy data */ heap_data->policy = policy; diff --git a/src/repl/lru/store_repl_lru.cc b/src/repl/lru/store_repl_lru.cc index 22208d865a..61f1b18421 100644 --- a/src/repl/lru/store_repl_lru.cc +++ b/src/repl/lru/store_repl_lru.cc @@ -1,6 +1,6 @@ /* - * $Id: store_repl_lru.cc,v 1.17 2006/05/08 23:38:35 robertc Exp $ + * $Id: store_repl_lru.cc,v 1.18 2006/08/21 00:50:47 robertc Exp $ * * DEBUG: section ? LRU Removal policy * AUTHOR: Henrik Nordstrom @@ -189,7 +189,7 @@ lru_walkDone(RemovalPolicyWalker * walker) assert(lru->nwalkers > 0); lru->nwalkers -= 1; safe_free(walker->_data); - cbdataFree(walker); + delete walker; } static RemovalPolicyWalker * @@ -199,7 +199,7 @@ lru_walkInit(RemovalPolicy * policy) RemovalPolicyWalker *walker; LruWalkData *lru_walk; lru->nwalkers += 1; - walker = cbdataAlloc(RemovalPolicyWalker); + walker = new RemovalPolicyWalker; lru_walk = (LruWalkData *)xcalloc(1, sizeof(*lru_walk)); walker->_policy = policy; walker->_data = lru_walk; @@ -268,7 +268,7 @@ lru_purgeDone(RemovalPurgeWalker * walker) assert(lru->nwalkers > 0); lru->nwalkers -= 1; safe_free(walker->_data); - cbdataFree(walker); + delete walker; } static RemovalPurgeWalker * @@ -278,7 +278,7 @@ lru_purgeInit(RemovalPolicy * policy, int max_scan) RemovalPurgeWalker *walker; LruPurgeData *lru_walk; lru->nwalkers += 1; - walker = cbdataAlloc(RemovalPurgeWalker); + walker = new RemovalPurgeWalker; lru_walk = (LruPurgeData *)xcalloc(1, sizeof(*lru_walk)); walker->_policy = policy; walker->_data = lru_walk; @@ -320,7 +320,7 @@ lru_free(RemovalPolicy * policy) /* Ok, time to destroy this policy */ safe_free(lru); memset(policy, 0, sizeof(*policy)); - cbdataFree(policy); + delete policy; } RemovalPolicy * @@ -341,7 +341,7 @@ createRemovalPolicy_lru(wordlist * args) /* Allocate the needed structures */ lru_data = (LruPolicyData *)xcalloc(1, sizeof(*lru_data)); - policy = cbdataAlloc(RemovalPolicy); + policy = new RemovalPolicy; /* Initialize the URL data */ lru_data->policy = policy; diff --git a/src/store_digest.cc b/src/store_digest.cc index f2a7885421..7be9ce8fb9 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: store_digest.cc,v 1.69 2006/08/07 02:28:22 robertc Exp $ + * $Id: store_digest.cc,v 1.70 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -49,6 +49,7 @@ #include "HttpRequest.h" #include "HttpReply.h" #include "MemObject.h" +#include "PeerDigest.h" #include "SquidTime.h" #include "StoreSearch.h" @@ -62,7 +63,7 @@ class StoreDigestState public: StoreDigestCBlock cblock; int rebuild_lock; /* bucket number */ - generic_cbdata *rewrite_lock; /* points to store entry with the digest */ + StoreEntry * rewrite_lock; /* points to store entry with the digest */ StoreSearchPointer theSearch; int rewrite_offset; int rebuild_count; @@ -403,8 +404,7 @@ storeDigestRewriteStart(void *datanotused) flags.cachable = 1; e = storeCreateEntry(url, url, flags, METHOD_GET); assert(e); - sd_state.rewrite_lock = cbdataAlloc(generic_cbdata); - sd_state.rewrite_lock->data = e; + sd_state.rewrite_lock = e; debug(71, 3) ("storeDigestRewrite: url: %s key: %s\n", url, e->getMD5Text()); HttpRequest *req = HttpRequest::CreateFromUrl(url); e->mem_obj->request = HTTPMSGLOCK(req); @@ -425,7 +425,7 @@ storeDigestRewriteResume(void) assert(sd_state.rewrite_lock); assert(!sd_state.rebuild_lock); - e = (StoreEntry *)sd_state.rewrite_lock->data; + e = sd_state.rewrite_lock; sd_state.rewrite_offset = 0; EBIT_SET(e->flags, ENTRY_SPECIAL); /* setting public key will purge old digest entry if any */ @@ -442,14 +442,14 @@ storeDigestRewriteResume(void) e->replaceHttpReply(rep); storeDigestCBlockSwapOut(e); storeBufferFlush(e); - eventAdd("storeDigestSwapOutStep", storeDigestSwapOutStep, sd_state.rewrite_lock, 0.0, 1); + eventAdd("storeDigestSwapOutStep", storeDigestSwapOutStep, sd_state.rewrite_lock, 0.0, 1, false); } /* finishes swap out sequence for the digest; schedules next rewrite */ static void storeDigestRewriteFinish(StoreEntry * e) { - assert(sd_state.rewrite_lock && e == sd_state.rewrite_lock->data); + assert(e == sd_state.rewrite_lock); e->complete(); storeTimestampsSet(e); debug(71, 2) ("storeDigestRewriteFinish: digest expires at %ld (%+d)\n", @@ -457,7 +457,6 @@ storeDigestRewriteFinish(StoreEntry * e) /* is this the write order? @?@ */ e->mem_obj->unlinkRequest(); e->unlock(); - cbdataFree(sd_state.rewrite_lock); sd_state.rewrite_lock = NULL; sd_state.rewrite_count++; eventAdd("storeDigestRewriteStart", storeDigestRewriteStart, NULL, (double) @@ -472,10 +471,9 @@ storeDigestRewriteFinish(StoreEntry * e) static void storeDigestSwapOutStep(void *data) { - StoreEntry *e; + StoreEntry *e = static_cast(data); int chunk_size = Config.digest.swapout_chunk_size; - assert(data == sd_state.rewrite_lock); - e = (StoreEntry *) ((generic_cbdata *) data)->data; + assert(e == sd_state.rewrite_lock); assert(e); /* _add_ check that nothing bad happened while we were waiting @?@ @?@ */ @@ -494,7 +492,7 @@ storeDigestSwapOutStep(void *data) if ((size_t)sd_state.rewrite_offset >= store_digest->mask_size) storeDigestRewriteFinish(e); else - eventAdd("storeDigestSwapOutStep", storeDigestSwapOutStep, data, 0.0, 1); + eventAdd("storeDigestSwapOutStep", storeDigestSwapOutStep, data, 0.0, 1, false); } static void diff --git a/src/store_dir.cc b/src/store_dir.cc index 3a6447ba85..a7449e873e 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.155 2006/08/19 12:31:21 robertc Exp $ + * $Id: store_dir.cc,v 1.156 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -893,6 +893,7 @@ StoreHashIndex::search(String const url, HttpRequest *) } CBDATA_CLASS_INIT(StoreSearchHashIndex); + StoreSearchHashIndex::StoreSearchHashIndex(RefCount aSwapDir) : sd(aSwapDir), _done (false), bucket (0) {} diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 10494b99dd..a531c1b9ae 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.cc,v 1.107 2006/05/31 17:24:23 wessels Exp $ + * $Id: store_swapout.cc,v 1.108 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "cbdata.h" #include "StoreClient.h" #include "Store.h" /* FIXME: Abstract the use of this more */ @@ -62,13 +63,12 @@ storeSwapOutStart(StoreEntry * e) * then this code needs changing */ /* Create the swap file */ - generic_cbdata *c = cbdataAlloc(generic_cbdata); - c->data = e; + generic_cbdata *c = new generic_cbdata(e); sio = storeCreate(e, storeSwapOutFileNotify, storeSwapOutFileClosed, c); if (NULL == sio.getRaw()) { e->swap_status = SWAPOUT_NONE; - cbdataFree(c); + delete c; storeLog(STORE_LOG_SWAPOUTFAIL, e); return; } diff --git a/src/structs.h b/src/structs.h index dbecfd81c2..c913a71228 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.546 2006/08/07 02:28:22 robertc Exp $ + * $Id: structs.h,v 1.547 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -179,15 +179,9 @@ struct _https_port_list #include "DelayConfig.h" #endif -class RemovalPolicySettings -{ - -public: - RemovalPolicySettings() : type(NULL), args(NULL) {}; +/* forward decl for SquidConfig, see RemovalPolicy.h */ +class RemovalPolicySettings; - char *type; - wordlist *args; -}; class external_acl; @@ -961,53 +955,6 @@ struct _domain_type #if USE_CACHE_DIGESTS -struct _Version -{ - short int current; /* current version */ - short int required; /* minimal version that can safely handle current version */ -}; - -/* digest control block; used for transmission and storage */ - -struct _StoreDigestCBlock -{ - Version ver; - int capacity; - int count; - int del_count; - int mask_size; - unsigned char bits_per_entry; - unsigned char hash_func_count; - short int reserved_short; - int reserved[32 - 6]; -}; - -struct _DigestFetchState -{ - PeerDigest *pd; - StoreEntry *entry; - StoreEntry *old_entry; - store_client *sc; - store_client *old_sc; - HttpRequest *request; - int offset; - int mask_offset; - time_t start_time; - time_t resp_time; - time_t expires; - - struct - { - int msg; - int bytes; - } - - sent, recv; - char buf[SM_PAGE_SIZE]; - ssize_t bufofs; - digest_read_state_t state; -}; - /* statistics for cache digests and other hit "predictors" */ struct _cd_guess_stats @@ -1020,68 +967,6 @@ struct _cd_guess_stats int close_hits; /* tmp, remove it later */ }; -class PeerDigest -{ - -public: - void *operator new (size_t); - void operator delete(void *); - - struct _peer *peer; /* pointer back to peer structure, argh */ - CacheDigest *cd; /* actual digest structure */ - String host; /* copy of peer->host */ - const char *req_result; /* text status of the last request */ - - struct - { - -unsigned int needed: - 1; /* there were requests for this digest */ - -unsigned int usable: - 1; /* can be used for lookups */ - -unsigned int requested: - 1; /* in process of receiving [fresh] digest */ - } - - flags; - - struct - { - /* all times are absolute unless augmented with _delay */ - time_t initialized; /* creation */ - time_t needed; /* first lookup/use by a peer */ - time_t next_check; /* next scheduled check/refresh event */ - time_t retry_delay; /* delay before re-checking _invalid_ digest */ - time_t requested; /* requested a fresh copy of a digest */ - time_t req_delay; /* last request response time */ - time_t received; /* received the current copy of a digest */ - time_t disabled; /* disabled for good */ - } - - times; - - struct - { - cd_guess_stats guess; - int used_count; - - struct - { - int msgs; - kb_t kbytes; - } - - sent, recv; - } - - stats; - -private: - CBDATA_CLASS(PeerDigest); -}; - #endif struct _peer @@ -1343,47 +1228,6 @@ struct _iostats Http, Ftp, Gopher, Wais; }; -/* Removal policies */ - -class RemovalPolicyNode -{ - -public: - RemovalPolicyNode() : data(NULL) {} - - void *data; -}; - -struct _RemovalPolicy -{ - const char *_type; - void *_data; - void (*Free) (RemovalPolicy * policy); - void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node); - void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node); - void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node); - void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node); - RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy); - RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan); - void (*Stats) (RemovalPolicy * policy, StoreEntry * entry); -}; - -struct _RemovalPolicyWalker -{ - RemovalPolicy *_policy; - void *_data; - const StoreEntry *(*Next) (RemovalPolicyWalker * walker); - void (*Done) (RemovalPolicyWalker * walker); -}; - -struct _RemovalPurgeWalker -{ - RemovalPolicy *_policy; - void *_data; - int scanned, max_scan, locked; - StoreEntry *(*Next) (RemovalPurgeWalker * walker); - void (*Done) (RemovalPurgeWalker * walker); -}; struct request_flags { @@ -1531,45 +1375,6 @@ unsigned int ignore_auth: flags; }; -struct _ErrorState -{ - err_type type; - int page_id; - http_status httpStatus; - auth_user_request_t *auth_user_request; - HttpRequest *request; - char *url; - int xerrno; - u_short port; - char *dnsserver_msg; - time_t ttl; - - struct IN_ADDR src_addr; - char *redirect_url; - ERCB *callback; - void *callback_data; - - struct - { - -unsigned int flag_cbdata: - 1; - } - - flags; - - struct - { - wordlist *server_msg; - char *request; - char *reply; - } - - ftp; - char *request_hdrs; - char *err_msg; /* Preformatted error message from the cache */ -}; - /* * "very generic" histogram; * see important comments on hbase_f restrictions in StatHist.c @@ -1826,166 +1631,6 @@ struct _CacheDigest int del_count; /* number of deletions performed so far */ }; -class helper_request; - -struct _helper -{ - wordlist *cmdline; - dlink_list servers; - dlink_list queue; - const char *id_name; - int n_to_start; - int n_running; - int n_active; - int ipc_type; - unsigned int concurrency; - time_t last_queue_warn; - time_t last_restart; - - struct - { - int requests; - int replies; - int queue_size; - int avg_svc_time; - } - - stats; -}; - -struct _helper_stateful -{ - wordlist *cmdline; - dlink_list servers; - dlink_list queue; - const char *id_name; - int n_to_start; - int n_running; - int n_active; - int ipc_type; - MemAllocatorProxy *datapool; - HLPSAVAIL *IsAvailable; - HLPSONEQ *OnEmptyQueue; - time_t last_queue_warn; - time_t last_restart; - - struct - { - int requests; - int replies; - int queue_size; - int avg_svc_time; - } - - stats; -}; - -struct _helper_server -{ - int index; - int pid; - int rfd; - int wfd; - MemBuf *wqueue; - MemBuf *writebuf; - char *rbuf; - size_t rbuf_sz; - off_t roffset; - - struct timeval dispatch_time; - - struct timeval answer_time; - - dlink_node link; - helper *parent; - helper_request **requests; - - struct _helper_flags - { - -unsigned int writing: - 1; - -unsigned int closing: - 1; - -unsigned int shutdown: - 1; - } - - flags; - - struct - { - int uses; - unsigned int pending; - } - - stats; -}; - -class helper_stateful_request; - -struct _helper_stateful_server -{ - int index; - int pid; - int rfd; - int wfd; - /* MemBuf wqueue; */ - /* MemBuf writebuf; */ - char *rbuf; - size_t rbuf_sz; - off_t roffset; - - struct timeval dispatch_time; - - struct timeval answer_time; - - dlink_node link; - dlink_list queue; - statefulhelper *parent; - helper_stateful_request *request; - - struct _helper_stateful_flags - { - -unsigned int busy: - 1; - -unsigned int closing: - 1; - -unsigned int shutdown: - 1; - stateful_helper_reserve_t reserved; - } - - flags; - - struct - { - int uses; - int submits; - int releases; - int deferbyfunc; - int deferbycb; - } - - stats; - int deferred_requests; /* current number of deferred requests */ - void *data; /* State data used by the calling routines */ -}; - -/* - * use this when you need to pass callback data to a blocking - * operation, but you don't want to add that pointer to cbdata - */ - -struct _generic_cbdata -{ - void *data; -}; struct _store_rebuild_data { diff --git a/src/tests/stub_MemObject.cc b/src/tests/stub_MemObject.cc index bba22b5828..c65fd183a2 100644 --- a/src/tests/stub_MemObject.cc +++ b/src/tests/stub_MemObject.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_MemObject.cc,v 1.4 2006/04/25 07:13:33 robertc Exp $ + * $Id: stub_MemObject.cc,v 1.5 2006/08/21 00:50:47 robertc Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Robert Collins @@ -39,6 +39,8 @@ #include "DelayPools.h" #endif +RemovalPolicy * mem_policy = NULL; + off_t MemObject::endOffset () const { diff --git a/src/tests/stub_errorpage.cc b/src/tests/stub_errorpage.cc index cf0195f771..ddb5fb424c 100644 --- a/src/tests/stub_errorpage.cc +++ b/src/tests/stub_errorpage.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_errorpage.cc,v 1.2 2006/04/25 07:13:34 robertc Exp $ + * $Id: stub_errorpage.cc,v 1.3 2006/08/21 00:50:47 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Robert Collins @@ -32,7 +32,7 @@ * */ -#include "squid.h" +#include "errorpage.h" err_type errorReservePageId(const char *page_name) diff --git a/src/tests/stub_helper.cc b/src/tests/stub_helper.cc index fe3df26c29..6a7be44e0f 100644 --- a/src/tests/stub_helper.cc +++ b/src/tests/stub_helper.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_helper.cc,v 1.1 2004/08/30 03:29:02 robertc Exp $ + * $Id: stub_helper.cc,v 1.2 2006/08/21 00:50:47 robertc Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Robert Collins @@ -33,6 +33,7 @@ */ #include "squid.h" +#include "helper.h" void helperSubmit(helper * hlp, const char *buf, HLPCB * callback, void *data) @@ -58,10 +59,13 @@ helperFree(helper * hlp) fatal("Not implemented"); } +CBDATA_TYPE(helper); + helper * helperCreate(const char *name) { helper *hlp; + CBDATA_INIT_TYPE(helper); hlp = cbdataAlloc(helper); hlp->id_name = name; return hlp; @@ -123,10 +127,13 @@ helperStatefulReleaseServer(helper_stateful_server * srv) fatal("Not implemented"); } +CBDATA_TYPE(statefulhelper); + statefulhelper * helperStatefulCreate(const char *name) { statefulhelper *hlp; + CBDATA_INIT_TYPE(statefulhelper); hlp = cbdataAlloc(statefulhelper); hlp->id_name = name; return hlp; diff --git a/src/tests/testAuth.cc b/src/tests/testAuth.cc index 722275959f..a9d3659e8e 100644 --- a/src/tests/testAuth.cc +++ b/src/tests/testAuth.cc @@ -95,8 +95,6 @@ fake_auth_setup() Mem::Init(); - cbdataInit(); - Vector &config = Config.authConfiguration; char const *digest_parms[]= {"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd", diff --git a/src/tests/testCoss.cc b/src/tests/testCoss.cc index bafd610b09..38e68b0125 100644 --- a/src/tests/testCoss.cc +++ b/src/tests/testCoss.cc @@ -8,6 +8,7 @@ #include "fs/ufs/ufscommon.h" #include "fs/coss/CossSwapDir.h" #include "Mem.h" +#include "MemObject.h" #include "HttpHeader.h" #include "HttpReply.h" #include "StoreFileSystem.h" @@ -59,8 +60,6 @@ testCoss::commonInit() Mem::Init(); - cbdataInit(); - comm_init(); httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */ @@ -178,8 +177,7 @@ testCoss::testCossSearch() /* our swapdir must be scheduled to rebuild */ CPPUNIT_ASSERT_EQUAL(1, StoreController::store_dirs_rebuilding); - while (StoreController::store_dirs_rebuilding) - loop.runOnce(); + loop.run(); /* cannot use loop.run(); as the loop will never idle: the store-dir * clean() scheduled event prevents it diff --git a/src/tests/testEvent.cc b/src/tests/testEvent.cc index 9b30c2376d..2317a687bc 100644 --- a/src/tests/testEvent.cc +++ b/src/tests/testEvent.cc @@ -135,10 +135,13 @@ testEvent::testCheckEvents() EventDispatcher dispatcher; EventScheduler scheduler(&dispatcher); CalledEvent event; - CPPUNIT_ASSERT_EQUAL(10, scheduler.checkEvents(0)); - /* event running now gets sent to the dispatcher and the delay is set to 10ms */ + /* with no events, its an idle engine */ + CPPUNIT_ASSERT_EQUAL(int(AsyncEngine::EVENT_IDLE), scheduler.checkEvents(0)); + /* event running now gets will get sent to the dispatcher and the + * engine becomes idle. + */ scheduler.schedule("test event", CalledEvent::Handler, &event, 0, 0, false); - CPPUNIT_ASSERT_EQUAL(10, scheduler.checkEvents(0)); + CPPUNIT_ASSERT_EQUAL(int(AsyncEngine::EVENT_IDLE), scheduler.checkEvents(0)); dispatcher.dispatch(); /* event running later results in a delay of the time till it runs */ scheduler.schedule("test event", CalledEvent::Handler, &event, 2, 0, false); diff --git a/src/tests/testHeader_RemovalPolicy.cc b/src/tests/testHeader_RemovalPolicy.cc new file mode 100644 index 0000000000..fdde7cbc6e --- /dev/null +++ b/src/tests/testHeader_RemovalPolicy.cc @@ -0,0 +1,4 @@ +/* This test tests that the header below can be processed on its own with + * no other #includes. Dont add any! + */ +#include "RemovalPolicy.h" diff --git a/src/tests/testHeader_cbdata.cc b/src/tests/testHeader_cbdata.cc new file mode 100644 index 0000000000..9bc24cf96a --- /dev/null +++ b/src/tests/testHeader_cbdata.cc @@ -0,0 +1,4 @@ +/* This test tests that the header below can be processed on its own with + * no other #includes. Dont add any! + */ +#include "cbdata.h" diff --git a/src/tests/testHeader_errorpage.cc b/src/tests/testHeader_errorpage.cc new file mode 100644 index 0000000000..8e2da243e9 --- /dev/null +++ b/src/tests/testHeader_errorpage.cc @@ -0,0 +1,4 @@ +/* This test tests that the header below can be processed on its own with + * no other #includes. Dont add any! + */ +#include "errorpage.h" diff --git a/src/tests/testNull.cc b/src/tests/testNull.cc index ab6d92d040..f81f1e38da 100644 --- a/src/tests/testNull.cc +++ b/src/tests/testNull.cc @@ -8,6 +8,7 @@ #include "fs/ufs/ufscommon.h" #include "fs/null/store_null.h" #include "Mem.h" +#include "MemObject.h" #include "HttpHeader.h" #include "HttpReply.h" #include "StoreFileSystem.h" @@ -59,8 +60,6 @@ testNull::commonInit() Mem::Init(); - cbdataInit(); - comm_init(); httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */ @@ -148,12 +147,7 @@ testNull::testNullSearch() */ CPPUNIT_ASSERT_EQUAL(1, StoreController::store_dirs_rebuilding); - while (StoreController::store_dirs_rebuilding) - loop.runOnce(); - - /* cannot use loop.run(); as the loop will never idle: the store-dir - * clean() scheduled event prevents it - */ + loop.run(); /* nothing left to rebuild */ CPPUNIT_ASSERT_EQUAL(0, StoreController::store_dirs_rebuilding); diff --git a/src/tests/testStoreController.cc b/src/tests/testStoreController.cc index 17a76fc474..479c7791ea 100644 --- a/src/tests/testStoreController.cc +++ b/src/tests/testStoreController.cc @@ -49,8 +49,6 @@ commonInit() Mem::Init(); - cbdataInit(); - Config.Store.avgObjectSize = 1024; Config.Store.objectsPerBucket = 20; diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index fc150fb375..c3e724dbb0 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -7,6 +7,7 @@ #include "DiskIO/DiskIOModule.h" #include "fs/ufs/ufscommon.h" #include "Mem.h" +#include "MemObject.h" #include "HttpHeader.h" #include "HttpReply.h" #include "testStoreSupport.h" @@ -76,8 +77,6 @@ testUfs::testUfsSearch() Mem::Init(); - cbdataInit(); - comm_init(); httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */ diff --git a/src/tunnel.cc b/src/tunnel.cc index c36ec99e58..d266cad238 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.162 2006/05/06 22:13:18 wessels Exp $ + * $Id: tunnel.cc,v 1.163 2006/08/21 00:50:41 robertc Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "errorpage.h" #include "HttpRequest.h" #include "fde.h" #include "comm.h" diff --git a/src/typedefs.h b/src/typedefs.h index 2f1724b0ff..7f8f5af9d6 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.187 2006/08/07 02:28:22 robertc Exp $ + * $Id: typedefs.h,v 1.188 2006/08/21 00:50:41 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -139,8 +139,6 @@ typedef struct _domain_type domain_type; typedef struct _DynPool DynPool; -typedef struct _StoreDigestCBlock StoreDigestCBlock; - typedef struct _DigestFetchState DigestFetchState; class PeerDigest; @@ -171,10 +169,6 @@ class StoreEntry; class SwapDir; -typedef struct _helper_flags helper_flags; - -typedef struct _helper_stateful_flags helper_stateful_flags; - typedef struct _http_state_flags http_state_flags; typedef struct _header_mangler header_mangler; @@ -189,8 +183,6 @@ typedef struct _refresh_t refresh_t; typedef struct _CommWriteStateData CommWriteStateData; -typedef struct _ErrorState ErrorState; - typedef struct _StatCounters StatCounters; typedef struct _storeSwapLogData storeSwapLogData; @@ -205,16 +197,6 @@ typedef struct _CacheDigest CacheDigest; typedef struct _Version Version; -typedef struct _helper helper; - -typedef struct _helper_stateful statefulhelper; - -typedef struct _helper_server helper_server; - -typedef struct _helper_stateful_server helper_stateful_server; - -typedef struct _generic_cbdata generic_cbdata; - typedef struct _link_list link_list; typedef struct _Logfile Logfile; @@ -225,12 +207,6 @@ typedef struct _logformat logformat; typedef struct _customlog customlog; -typedef struct _RemovalPolicy RemovalPolicy; - -typedef struct _RemovalPolicyWalker RemovalPolicyWalker; - -typedef struct _RemovalPurgeWalker RemovalPurgeWalker; - #if SQUID_SNMP typedef variable_list *(oid_ParseFn) (variable_list *, snint *); @@ -273,7 +249,6 @@ typedef void OBJH(StoreEntry *); typedef void SIGHDLR(int sig); typedef void STVLDCB(void *, int, int); typedef void HLPCB(void *, char *buf); -typedef stateful_helper_callback_t HLPSCB(void *, void *lastserver, char *buf); typedef int HLPSAVAIL(void *); typedef void HLPSONEQ(void *); typedef void HLPCMDOPTS(int *argc, char **argv); @@ -291,7 +266,5 @@ typedef int Ctx; /* in case we want to change it later */ typedef ssize_t mb_size_t; -typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args); - typedef int STDIRSELECT(const StoreEntry *); #endif /* SQUID_TYPEDEFS_H */ diff --git a/src/urn.cc b/src/urn.cc index 9a59b06dfd..c759440731 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,6 +1,6 @@ /* - * $Id: urn.cc,v 1.101 2006/05/19 17:19:10 wessels Exp $ + * $Id: urn.cc,v 1.102 2006/08/21 00:50:42 robertc Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "errorpage.h" #include "StoreClient.h" #include "Store.h" #include "HttpReply.h" diff --git a/src/wais.cc b/src/wais.cc index 29af70d6f0..4b8656617f 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $Id: wais.cc,v 1.160 2006/05/19 17:19:10 wessels Exp $ + * $Id: wais.cc,v 1.161 2006/08/21 00:50:42 robertc Exp $ * * DEBUG: section 24 WAIS Relay * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "errorpage.h" #include "Store.h" #include "HttpRequest.h" #if DELAY_POOLS diff --git a/src/whois.cc b/src/whois.cc index 30f9a61119..51d22232c8 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -1,6 +1,6 @@ /* - * $Id: whois.cc,v 1.35 2006/05/19 17:19:10 wessels Exp $ + * $Id: whois.cc,v 1.36 2006/08/21 00:50:42 robertc Exp $ * * DEBUG: section 75 WHOIS protocol * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "errorpage.h" #include "Store.h" #include "HttpReply.h" #include "HttpRequest.h"