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