]>
Commit | Line | Data |
---|---|---|
528b2c61 | 1 | |
2 | /* | |
60745f24 | 3 | * $Id: MemObject.h,v 1.16 2008/01/20 08:54:28 amosjeffries Exp $ |
528b2c61 | 4 | * |
5 | * | |
6 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
7 | * ---------------------------------------------------------- | |
8 | * | |
9 | * Squid is the result of efforts by numerous individuals from | |
10 | * the Internet community; see the CONTRIBUTORS file for full | |
11 | * details. Many organizations have provided support for Squid's | |
12 | * development; see the SPONSORS file for full details. Squid is | |
13 | * Copyrighted (C) 2001 by the Regents of the University of | |
14 | * California; see the COPYRIGHT file for full details. Squid | |
15 | * incorporates software developed and/or copyrighted by other | |
16 | * sources; see the CREDITS file for full details. | |
17 | * | |
18 | * This program is free software; you can redistribute it and/or modify | |
19 | * it under the terms of the GNU General Public License as published by | |
20 | * the Free Software Foundation; either version 2 of the License, or | |
21 | * (at your option) any later version. | |
22 | * | |
23 | * This program is distributed in the hope that it will be useful, | |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 | * GNU General Public License for more details. | |
27 | * | |
28 | * You should have received a copy of the GNU General Public License | |
29 | * along with this program; if not, write to the Free Software | |
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
31 | * | |
32 | */ | |
33 | ||
34 | #ifndef SQUID_MEMOBJECT_H | |
35 | #define SQUID_MEMOBJECT_H | |
36 | ||
37 | #include "StoreIOBuffer.h" | |
e877aaac | 38 | #include "StoreIOState.h" |
528b2c61 | 39 | #include "stmem.h" |
a46d2c0e | 40 | #include "CommRead.h" |
aa839030 | 41 | #include "RemovalPolicy.h" |
528b2c61 | 42 | |
43 | typedef void STMCB (void *data, StoreIOBuffer wroteBuffer); | |
44 | ||
45 | class store_client; | |
b67e2c8c | 46 | #if DELAY_POOLS |
47 | #include "DelayId.h" | |
48 | #endif | |
528b2c61 | 49 | |
62e76326 | 50 | class MemObject |
51 | { | |
52 | ||
528b2c61 | 53 | public: |
54 | static size_t inUseCount(); | |
b001e822 | 55 | MEMPROXY_CLASS(MemObject); |
62e76326 | 56 | |
528b2c61 | 57 | void dump() const; |
528b2c61 | 58 | MemObject(char const *, char const *); |
59 | ~MemObject(); | |
60 | ||
61 | void write(StoreIOBuffer, STMCB *, void *); | |
62 | void unlinkRequest(); | |
63 | HttpReply const *getReply() const; | |
4a56ee8d | 64 | void replaceHttpReply(HttpReply *newrep); |
fcc35180 | 65 | void stat (MemBuf * mb) const; |
47f6e231 | 66 | int64_t endOffset () const; |
67 | int64_t size() const; | |
528b2c61 | 68 | void reset(); |
47f6e231 | 69 | int64_t lowestMemReaderOffset() const; |
528b2c61 | 70 | bool readAheadPolicyCanRead() const; |
71 | void addClient(store_client *); | |
62e76326 | 72 | /* XXX belongs in MemObject::swapout, once swaphdrsz is managed |
528b2c61 | 73 | * better |
74 | */ | |
47f6e231 | 75 | int64_t objectBytesOnDisk() const; |
76 | int64_t policyLowestOffsetToKeep() const; | |
528b2c61 | 77 | void trimSwappable(); |
78 | void trimUnSwappable(); | |
79 | bool isContiguous() const; | |
b67e2c8c | 80 | int mostBytesWanted(int max) const; |
a46d2c0e | 81 | void setNoDelay(bool const newValue); |
b67e2c8c | 82 | #if DELAY_POOLS |
62e76326 | 83 | |
b67e2c8c | 84 | DelayId mostBytesAllowed() const; |
85 | #endif | |
528b2c61 | 86 | |
87 | ||
88 | #if URL_CHECKSUM_DEBUG | |
62e76326 | 89 | |
528b2c61 | 90 | void checkUrlChecksum() const; |
91 | #endif | |
92 | ||
60745f24 | 93 | HttpRequestMethod method; |
528b2c61 | 94 | char *url; |
95 | mem_hdr data_hdr; | |
47f6e231 | 96 | int64_t inmem_lo; |
528b2c61 | 97 | dlink_list clients; |
0e3f3e0d | 98 | /* TODO: move into .cc or .cci */ |
99 | size_t clientCount() const {return nclients;} | |
100 | ||
101 | bool clientIsFirst(void *sc) const {return (clients.head && sc == clients.head->data);} | |
102 | ||
528b2c61 | 103 | int nclients; |
62e76326 | 104 | |
ecf22804 | 105 | class SwapOut |
62e76326 | 106 | { |
ecf22804 | 107 | |
108 | public: | |
47f6e231 | 109 | int64_t queue_offset; /* relative to in-mem data */ |
528b2c61 | 110 | mem_node *memnode; /* which node we're currently paging out */ |
62e76326 | 111 | StoreIOState::Pointer sio; |
ecf22804 | 112 | }; |
62e76326 | 113 | |
ecf22804 | 114 | SwapOut swapout; |
528b2c61 | 115 | /* Read only - this reply must be preserved by store clients */ |
116 | /* The original reply. possibly with updated metadata. */ | |
190154cf | 117 | HttpRequest *request; |
62e76326 | 118 | |
528b2c61 | 119 | struct timeval start_ping; |
120 | IRCB *ping_reply_callback; | |
121 | void *ircb_data; | |
62e76326 | 122 | |
123 | struct | |
124 | { | |
528b2c61 | 125 | STABH *callback; |
126 | void *data; | |
62e76326 | 127 | } |
128 | ||
129 | abort; | |
528b2c61 | 130 | char *log_url; |
131 | RemovalPolicyNode repl; | |
132 | int id; | |
47f6e231 | 133 | int64_t object_sz; |
528b2c61 | 134 | size_t swap_hdr_sz; |
135 | #if URL_CHECKSUM_DEBUG | |
62e76326 | 136 | |
528b2c61 | 137 | unsigned int chksum; |
138 | #endif | |
62e76326 | 139 | |
528b2c61 | 140 | const char *vary_headers; |
62e76326 | 141 | |
a46d2c0e | 142 | void delayRead(DeferredRead const &); |
143 | void kickReads(); | |
144 | ||
528b2c61 | 145 | private: |
4a56ee8d | 146 | HttpReply *_reply; |
4a56ee8d | 147 | |
a46d2c0e | 148 | DeferredReadManager deferredReads; |
528b2c61 | 149 | }; |
150 | ||
b001e822 | 151 | MEMPROXY_CLASS_INLINE(MemObject) |
152 | ||
aa839030 | 153 | /* global current memory removal policy */ |
154 | extern RemovalPolicy *mem_policy; | |
155 | ||
528b2c61 | 156 | #endif /* SQUID_MEMOBJECT_H */ |