/*
- * $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/
#ifndef SQUID_LIST_H
#define SQUID_LIST_H
+#include "cbdata.h"
+
template <class C>
class List
/*
- * $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/
#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.
/*
- * $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/
* ----------------------------------------------------------
#include "DiskIO/DiskFile.h"
#include "async_io.h"
+#include "cbdata.h"
class AIODiskIOStrategy;
/*
- * $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
#ifndef SQUID_BLOCKINGFILE_H
#define SQUID_BLOCKINGFILE_H
+
+#include "cbdata.h"
#include "DiskIO/DiskFile.h"
class BlockingFile : public DiskFile
/*
- * $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
#ifndef __STORE_DISKDFILE_H__
#define __STORE_DISKDFILE_H__
+#include "cbdata.h"
#include "DiskIO/DiskFile.h"
class DiskdIOStrategy;
/*
- * $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
#ifndef SQUID_DISKTHREADSDISKFILE_H
#define SQUID_DISKTHREADSDISKFILE_H
+#include "cbdata.h"
#include "DiskIO/DiskFile.h"
#include "DiskThreads.h"
/*
- * $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/
* ----------------------------------------------------------
#include "squid.h"
+#include "cbdata.h"
#include "RefCount.h"
class ReadRequest : public RefCountable
/*
- * $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/
* ----------------------------------------------------------
#include "squid.h"
+#include "cbdata.h"
#include "RefCount.h"
class WriteRequest : public RefCountable
/*
- * $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
#include "ESI.h"
#include "clientStream.h"
#include "client_side_request.h"
+#include "errorpage.h"
#include "ESISegment.h"
#include "ESIElement.h"
#include "ESIContext.h"
/*
- * $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/
* or perhaps use membuffers here?
*/
+#include "cbdata.h"
#include "RefCount.h"
#include "SquidString.h"
/*
- * $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
#ifndef SQUID_EXTERNALACLENTRY_H
#define SQUID_EXTERNALACLENTRY_H
+
+#include "cbdata.h"
+
/******************************************************************
* ExternalACLEntryData
* Core data that ExternalACLEntry manages.
/*
- * $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/
#ifndef SQUID_ICAPSERVICEREP_H
#define SQUID_ICAPSERVICEREP_H
+#include "cbdata.h"
#include "ICAPElements.h"
class ICAPOptions;
/*
- * $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/
#ifndef SQUID_MSGPIPE_H
#define SQUID_MSGPIPE_H
+#include "cbdata.h"
#include "event.h"
// MsgPipe is a unidirectional communication channel for asynchronously
#
# 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:
#
CacheManager.h \
carp.cc \
cbdata.cc \
+ cbdata.h \
client_db.cc \
client_side.cc \
client_side.h \
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 \
SwapDir.h \
time.cc \
tools.cc \
+ tunnel.cc \
typedefs.h \
$(UNLINKDSOURCE) \
url.cc \
$(DNSSOURCE) \
enums.h \
errorpage.cc \
+ errorpage.h \
$(ESI_SOURCE) \
ETag.cc \
event.cc \
redirect.cc \
referer.cc \
refresh.cc \
+ RemovalPolicy.cc \
send-announce.cc \
$(SNMP_SOURCE) \
squid.h \
redirect.cc \
referer.cc \
refresh.cc \
+ RemovalPolicy.cc \
Server.cc \
$(SNMP_SOURCE) \
$(SSL_SOURCE) \
HttpRequest.cc \
HttpRequestMethod.cc \
mem.cc \
+ RemovalPolicy.cc \
String.cc \
tests/testEvent.cc \
tests/testEvent.h \
HttpRequest.cc \
HttpRequestMethod.cc \
mem.cc \
+ RemovalPolicy.cc \
String.cc \
tests/testEventLoop.cc \
tests/testEventLoop.h \
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 \
redirect.cc \
referer.cc \
refresh.cc \
+ RemovalPolicy.cc \
Server.cc \
$(SNMP_SOURCE) \
$(SSL_SOURCE) \
redirect.cc \
referer.cc \
refresh.cc \
+ RemovalPolicy.cc \
Server.cc \
$(SNMP_SOURCE) \
$(SSL_SOURCE) \
EventLoop.cc \
event.cc \
HttpMsg.cc \
+ RemovalPolicy.cc \
store_dir.cc \
store.cc \
HttpRequestMethod.cc \
HttpRequest.cc \
HttpRequestMethod.cc \
mem.cc \
+ RemovalPolicy.cc \
String.cc \
tests/testURL.cc \
tests/testURL.h \
/*
- * $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/
#ifndef SQUID_MEMBUF_H
#define SQUID_MEMBUF_H
+#include "cbdata.h"
#include "Packer.h"
/* auto-growing memory-resident buffer with printf interface */
/*
- * $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
#endif
+RemovalPolicy * mem_policy = NULL;
+
size_t
MemObject::inUseCount()
{
/*
- * $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/
#include "StoreIOState.h"
#include "stmem.h"
#include "CommRead.h"
+#include "RemovalPolicy.h"
typedef void STMCB (void *data, StoreIOBuffer wroteBuffer);
MEMPROXY_CLASS_INLINE(MemObject)
+/* global current memory removal policy */
+extern RemovalPolicy *mem_policy;
+
#endif /* SQUID_MEMOBJECT_H */
--- /dev/null
+
+/*
+ * $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 */
/*
- * $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
*
#ifndef SQUID_PEERSELECTSTATE_H
#define SQUID_PEERSELECTSTATE_H
+#include "cbdata.h"
#include "PingData.h"
class ps_state
ping_data ping;
ACLChecklist *acl_checklist;
+private:
+ CBDATA_CLASS(ps_state);
};
--- /dev/null
+
+/*
+ * $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);
--- /dev/null
+
+/*
+ * $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 <robertc@squid-cache.org>
+ */
+
+#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 */
/*
- * $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/
#include "RefCount.h"
#include "CommRead.h"
#include "Packer.h"
+#include "RemovalPolicy.h"
#if ESI
#include "ESIElement.h"
/*
- * $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/
#ifndef SQUID_STOREIOSTATE_H
#define SQUID_STOREIOSTATE_H
+#include "cbdata.h"
#include "RefCount.h"
class StoreIOState : public RefCountable
/*
- * $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/
#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) */
/*
- * $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
#include "ACL.h"
#include "ACLChecklist.h"
#include "ConfigParser.h"
+#include "errorpage.h"
#include "HttpRequest.h"
#include "AuthUser.h"
#include "AuthUserRequest.h"
#include "AuthConfig.h"
+#include "helper.h"
#define DefaultAuthenticateChildrenMax 32 /* 32 processes */
#include "AuthUser.h"
#include "AuthUserRequest.h"
#include "AuthConfig.h"
+#include "helper.h"
+
/* Generic */
class DigestAuthenticateStateData
#include "AuthUser.h"
#include "AuthUserRequest.h"
#include "AuthConfig.h"
+#include "helper.h"
#define DefaultAuthenticateChildrenMax 32 /* 32 processes */
#include "AuthUser.h"
#include "AuthUserRequest.h"
#include "AuthConfig.h"
+#include "helper.h"
#define DefaultAuthenticateChildrenMax 32 /* 32 processes */
/*
- * $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
*/
#include "CacheManager.h"
+#include "errorpage.h"
#include "HttpReply.h"
#include "HttpRequest.h"
#include "Store.h"
/*
- * $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
* when finished.
*/
-#include "squid.h"
+#include "cbdata.h"
#include "CacheManager.h"
#include "Store.h"
#if CBDATA_DEBUG
#endif
#include "Generic.h"
-/* XXX Remove me */
-#include "PeerSelectState.h"
-
static int cbdataCount = 0;
#if CBDATA_DEBUG
dlink_list cbdataEntries;
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);
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)
{
#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;
* 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;
}
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<CBDataCall, void>
--- /dev/null
+
+/*
+ * $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 <robertc@squid-cache.org>
+ */
+
+#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) {}
+ template<typename wrapped_type>void unwrap(wrapped_type **output)
+ {
+ *output = static_cast<wrapped_type *>(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 */
/*
- * $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)
#include "squid.h"
#include "client_side_reply.h"
+#include "errorpage.h"
#include "StoreClient.h"
#include "Store.h"
#include "HttpReply.h"
/*
- * $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/
#include "StoreClient.h"
#include "client_side_request.h"
+
+class ErrorState;
+
/* XXX make static method */
class clientReplyContext : public RefCountable, public StoreClient
/*
- * $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/
#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
/*
- * $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/
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)
*/
/*
- * $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
* Config.errorDirectory)
*/
-#include "squid.h"
+#include "errorpage.h"
#include "AuthUserRequest.h"
#include "SquidTime.h"
#include "Store.h"
#include "URLScheme.h"
#include "wordlist.h"
+CBDATA_CLASS_INIT(ErrorState);
+
/* local types */
typedef struct
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;
--- /dev/null
+
+/*
+ * $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 <robertc@squid-cache.org>
+ */
+
+#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 */
/*
- * $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
EventScheduler::checkDelay()
{
if (!tasks)
- return (int) 10;
+ return EVENT_IDLE;
int result = (int) ((tasks->when - current_dtime) * 1000);
/*
- * $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
#include "client_side.h"
#include "HttpRequest.h"
#include "authenticate.h"
+#include "helper.h"
#include "MemBuf.h"
#include "URLScheme.h"
#include "wordlist.h"
/*
- * $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
#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;
/* forward decls */
class CacheManager;
+class ErrorState;
#include "comm.h"
/*
- * $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
*/
#include "squid.h"
+#include "cbdata.h"
#include "event.h"
#include "CacheManager.h"
#include "SquidTime.h"
#endif
+
static void
#if USE_DNSSERVERS
fqdncacheHandleReply(void *data, char *reply)
#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<generic_cbdata *>(data)->unwrap(&f);
n = ++FqdncacheStats.replies;
statHistCount(&statCounter.dns.svc_time,
tvSubMsec(f->request_time, current_time));
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);
/*
- * $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
#include "Store.h"
#include "HttpRequest.h"
#include "HttpReply.h"
+#include "errorpage.h"
#include "fde.h"
#include "comm.h"
#include "HttpHeaderRange.h"
/*
- * $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/
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
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_
/*
- * $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
*/
#include "squid.h"
+#include "errorpage.h"
#include "Store.h"
#include "HttpRequest.h"
#include "comm.h"
/*
- * $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?
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)
{
hlp->n_running++;
hlp->n_active++;
+ CBDATA_INIT_TYPE(helper_server);
srv = cbdataAlloc(helper_server);
srv->pid = x;
srv->index = k;
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;
helperCreate(const char *name)
{
helper *hlp;
+ CBDATA_INIT_TYPE(helper);
hlp = cbdataAlloc(helper);
hlp->id_name = name;
return hlp;
helperStatefulCreate(const char *name)
{
statefulhelper *hlp;
+ CBDATA_INIT_TYPE(statefulhelper);
hlp = cbdataAlloc(statefulhelper);
hlp->id_name = name;
return hlp;
/*
- * $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?
#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
{
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 */
/*
- * $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
*/
#include "squid.h"
+#include "errorpage.h"
#include "MemBuf.h"
#include "http.h"
#include "AuthUserRequest.h"
/*
- * $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
*/
#include "squid.h"
+#include "errorpage.h"
#include "Store.h"
#include "HttpRequest.h"
#include "HttpReply.h"
/*
- * $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
*/
#include "squid.h"
+#include "cbdata.h"
#include "event.h"
#include "CacheManager.h"
#include "SquidTime.h"
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<generic_cbdata *>(data)->unwrap(&i);
IpcacheStats.replies++;
statHistCount(&statCounter.dns.svc_time,
tvSubMsec(i->request_time, current_time));
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);
/*
- * $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
#include "authenticate.h"
#include "CacheManager.h"
#include "ConfigParser.h"
+#include "errorpage.h"
#include "event.h"
#include "EventLoop.h"
#include "ExternalACL.h"
Mem::Init();
- cbdataInit();
-
storeFsInit(); /* required for config parsing */
/* May not be needed for parsing, have not audited for such */
/*
- * $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
*/
#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
/*
- * $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
*/
#include "squid.h"
+#include "cbdata.h"
#include "event.h"
#include "CacheManager.h"
#include "Store.h"
{
struct IN_ADDR addr;
- char *hostname = (char *)((generic_cbdata *) data)->data;
+ char *hostname;
+ static_cast<generic_cbdata *>(data)->unwrap(&hostname);
netdbEntry *n;
netdbEntry *na;
net_db_name *x;
net_db_name **X;
- cbdataFree(data);
if (ia == NULL) {
xfree(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
}
/*
- * $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
#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 */
/* local constants */
+Version const CacheDigestVer = { 5, 3 };
#define StoreDigestCBlockSize sizeof(StoreDigestCBlock)
/*
- * $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
static void peerGetAllParents(ps_state *);
static void peerAddFwdServer(FwdServer **, peer *, hier_code);
+CBDATA_CLASS_INIT(ps_state);
+
static void
peerSelectStateFree(ps_state * psstate)
{
void *
ps_state::operator new(size_t)
{
+ CBDATA_INIT_TYPE(ps_state);
return cbdataAlloc(ps_state);
}
/*
- * $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/
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);
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 *);
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);
SQUIDCEXTERN void logfilePrintf(va_alist);
#endif
-/*
- * Removal Policies
- */
-SQUIDCEXTERN RemovalPolicy *createRemovalPolicy(RemovalPolicySettings * settings);
-
/*
* prototypes for system functions missing from system includes
*/
/*
- * $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
#include "ACLChecklist.h"
#include "HttpRequest.h"
#include "client_side.h"
+#include "helper.h"
typedef struct
{
/*
- * $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
assert(heap->nwalkers > 0);
heap->nwalkers -= 1;
safe_free(walker->_data);
- cbdataFree(walker);
+ delete walker;
}
static RemovalPolicyWalker *
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;
}
safe_free(walker->_data);
- cbdataFree(walker);
+ delete walker;
}
static RemovalPurgeWalker *
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;
/* Ok, time to destroy this policy */
safe_free(heap);
memset(policy, 0, sizeof(*policy));
- cbdataFree(policy);
+ delete policy;
}
RemovalPolicy *
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;
/*
- * $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
assert(lru->nwalkers > 0);
lru->nwalkers -= 1;
safe_free(walker->_data);
- cbdataFree(walker);
+ delete walker;
}
static RemovalPolicyWalker *
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;
assert(lru->nwalkers > 0);
lru->nwalkers -= 1;
safe_free(walker->_data);
- cbdataFree(walker);
+ delete walker;
}
static RemovalPurgeWalker *
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;
/* Ok, time to destroy this policy */
safe_free(lru);
memset(policy, 0, sizeof(*policy));
- cbdataFree(policy);
+ delete policy;
}
RemovalPolicy *
/* 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;
/*
- * $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
#include "HttpRequest.h"
#include "HttpReply.h"
#include "MemObject.h"
+#include "PeerDigest.h"
#include "SquidTime.h"
#include "StoreSearch.h"
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;
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);
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 */
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",
/* 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)
static void
storeDigestSwapOutStep(void *data)
{
- StoreEntry *e;
+ StoreEntry *e = static_cast<StoreEntry *>(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 @?@ @?@ */
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
/*
- * $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
}
CBDATA_CLASS_INIT(StoreSearchHashIndex);
+
StoreSearchHashIndex::StoreSearchHashIndex(RefCount<StoreHashIndex> aSwapDir) : sd(aSwapDir), _done (false), bucket (0)
{}
/*
- * $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
*/
#include "squid.h"
+#include "cbdata.h"
#include "StoreClient.h"
#include "Store.h"
/* FIXME: Abstract the use of this more */
* 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;
}
/*
- * $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/
#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;
#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
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
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
{
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
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
{
/*
- * $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
#include "DelayPools.h"
#endif
+RemovalPolicy * mem_policy = NULL;
+
off_t
MemObject::endOffset () const
{
/*
- * $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
*
*/
-#include "squid.h"
+#include "errorpage.h"
err_type
errorReservePageId(const char *page_name)
/*
- * $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
*/
#include "squid.h"
+#include "helper.h"
void
helperSubmit(helper * hlp, const char *buf, HLPCB * callback, void *data)
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;
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;
Mem::Init();
- cbdataInit();
-
Vector<AuthConfig *> &config = Config.authConfiguration;
char const *digest_parms[]= {"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd",
#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"
Mem::Init();
- cbdataInit();
-
comm_init();
httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
/* 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
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);
--- /dev/null
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "RemovalPolicy.h"
--- /dev/null
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "cbdata.h"
--- /dev/null
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "errorpage.h"
#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"
Mem::Init();
- cbdataInit();
-
comm_init();
httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
*/
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);
Mem::Init();
- cbdataInit();
-
Config.Store.avgObjectSize = 1024;
Config.Store.objectsPerBucket = 20;
#include "DiskIO/DiskIOModule.h"
#include "fs/ufs/ufscommon.h"
#include "Mem.h"
+#include "MemObject.h"
#include "HttpHeader.h"
#include "HttpReply.h"
#include "testStoreSupport.h"
Mem::Init();
- cbdataInit();
-
comm_init();
httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
/*
- * $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
*/
#include "squid.h"
+#include "errorpage.h"
#include "HttpRequest.h"
#include "fde.h"
#include "comm.h"
/*
- * $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/
typedef struct _DynPool DynPool;
-typedef struct _StoreDigestCBlock StoreDigestCBlock;
-
typedef struct _DigestFetchState DigestFetchState;
class PeerDigest;
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;
typedef struct _CommWriteStateData CommWriteStateData;
-typedef struct _ErrorState ErrorState;
-
typedef struct _StatCounters StatCounters;
typedef struct _storeSwapLogData storeSwapLogData;
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;
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 *);
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);
/* 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 */
/*
- * $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
*/
#include "squid.h"
+#include "errorpage.h"
#include "StoreClient.h"
#include "Store.h"
#include "HttpReply.h"
/*
- * $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
*/
#include "squid.h"
+#include "errorpage.h"
#include "Store.h"
#include "HttpRequest.h"
#if DELAY_POOLS
/*
- * $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
*/
#include "squid.h"
+#include "errorpage.h"
#include "Store.h"
#include "HttpReply.h"
#include "HttpRequest.h"