MemObject.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_MEMOBJECT_H
10#define SQUID_MEMOBJECT_H
11
13#include "dlink.h"
14#include "http/RequestMethod.h"
15#include "HttpReply.h"
16#include "RemovalPolicy.h"
17#include "SquidString.h"
18#include "stmem.h"
19#include "store/forward.h"
20#include "StoreIOBuffer.h"
21#include "StoreIOState.h"
22#include "typedefs.h" //for IRCB
23
24#if USE_DELAY_POOLS
25#include "DelayId.h"
26#endif
27
28typedef void STMCB (void *data, StoreIOBuffer wroteBuffer);
29
30class store_client;
31class PeerSelector;
32
34{
36
37public:
38 static size_t inUseCount();
39
40 void dump() const;
41 MemObject();
42 ~MemObject();
43
50 void setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod);
51
53 bool hasUris() const;
54
55 void write(const StoreIOBuffer &buf);
56 void unlinkRequest() { request = nullptr; }
57
60 const HttpReply &baseReply() const { return *reply_; }
61
64 const HttpReplyPointer &updatedReply() const { return updatedReply_; }
65
68 const HttpReply &freshestReply() const {
69 if (updatedReply_)
70 return *updatedReply_;
71 else
72 return baseReply();
73 }
74
79
83
85 void updateReply(const HttpReply &r) { updatedReply_ = &r; }
86
90 bool appliedUpdates = false;
91
92 void stat (MemBuf * mb) const;
93
102 int64_t endOffset () const;
103
106
109 int64_t expectedReplySize() const;
110 int64_t size() const;
111 void reset();
112 int64_t lowestMemReaderOffset() const;
113 bool readAheadPolicyCanRead() const;
114 void addClient(store_client *);
115 /* XXX belongs in MemObject::swapout, once swaphdrsz is managed
116 * better
117 */
118 int64_t objectBytesOnDisk() const;
119 int64_t policyLowestOffsetToKeep(bool swap) const;
120 int64_t availableForSwapOut() const;
121 void trimSwappable();
122 void trimUnSwappable();
123 bool isContiguous() const;
124 int mostBytesWanted(int max, bool ignoreDelayPools) const;
125 void setNoDelay(bool const newValue);
126#if USE_DELAY_POOLS
128#endif
129
130#if URL_CHECKSUM_DEBUG
131
132 void checkUrlChecksum() const;
133#endif
134
138 const char *urlXXX() const { return storeId(); }
139
142 const char *storeId() const;
143
145 const char *logUri() const;
146
149 int64_t inmem_lo = 0;
151
152 size_t clientCount() const {return nclients;}
153
154 bool clientIsFirst(void *sc) const {return (clients.head && sc == clients.head->data);}
155
156 int nclients = 0;
157
159 {
160 public:
161 int64_t queue_offset = 0;
163
165 typedef enum { swNeedsCheck = 0, swImpossible = -1, swPossible = +1, swStarted } Decision;
167 };
168
170
171 /* TODO: Remove this change-minimizing hack */
174 static constexpr Io ioReading = Store::ioReading;
175 static constexpr Io ioWriting = Store::ioWriting;
176 static constexpr Io ioDone = Store::ioDone;
177
180 {
181 public:
183 void open(const int32_t anIndex, const Io anIo)
184 {
185 index = anIndex;
186 io = anIo;
187 }
188
190 void close()
191 {
192 index = -1;
194 }
195
196 int32_t index = -1;
198 };
200
203 {
204 public:
205 int32_t index = -1;
206 int64_t offset = 0;
207
209 };
211
213
214 struct timeval start_ping;
217
221 int id = 0;
222 int64_t object_sz = -1;
223 size_t swap_hdr_sz = 0;
224#if URL_CHECKSUM_DEBUG
225 unsigned int chksum = 0;
226#endif
227
229
230 void delayRead(const AsyncCallPointer &);
231 void kickReads();
232
233private:
236
237 mutable String storeId_;
238 mutable String logUri_;
239
241};
242
245
246#endif /* SQUID_MEMOBJECT_H */
247
RemovalPolicy * mem_policy
Definition: MemObject.cc:44
void STMCB(void *data, StoreIOBuffer wroteBuffer)
Definition: MemObject.h:28
Definition: MemBuf.h:24
State of an entry with regards to the [shared] memory caching.
Definition: MemObject.h:203
int32_t index
entry position inside the memory cache
Definition: MemObject.h:205
Io io
current I/O state
Definition: MemObject.h:208
int64_t offset
bytes written/read to/from the memory cache so far
Definition: MemObject.h:206
int64_t queue_offset
number of bytes sent to SwapDir for writing
Definition: MemObject.h:161
Decision decision
current decision state
Definition: MemObject.h:166
StoreIOState::Pointer sio
Definition: MemObject.h:162
Decision
Decision states for StoreEntry::swapoutPossible() and related code.
Definition: MemObject.h:165
State of an entry with regards to the [shared] in-transit table.
Definition: MemObject.h:180
void close()
stop associating our StoreEntry with a Transients entry
Definition: MemObject.h:190
int32_t index
entry position inside the in-transit table
Definition: MemObject.h:196
Io io
current I/O state
Definition: MemObject.h:197
void open(const int32_t anIndex, const Io anIo)
associate our StoreEntry with a Transients entry at the given index
Definition: MemObject.h:183
void replaceBaseReply(const HttpReplyPointer &r)
Definition: MemObject.cc:128
String storeId_
StoreId for our entry (usually request URI)
Definition: MemObject.h:237
bool appliedUpdates
Definition: MemObject.h:90
static constexpr Io ioDone
Definition: MemObject.h:176
RemovalPolicyNode repl
Definition: MemObject.h:220
int64_t lowestMemReaderOffset() const
Definition: MemObject.cc:277
DelayId mostBytesAllowed() const
Definition: MemObject.cc:466
IRCB * ping_reply_callback
Definition: MemObject.h:215
int64_t size() const
Definition: MemObject.cc:229
size_t clientCount() const
Definition: MemObject.h:152
const char * urlXXX() const
Definition: MemObject.h:138
int nclients
Definition: MemObject.h:156
static size_t inUseCount()
Definition: MemObject.cc:47
SwapOut swapout
Definition: MemObject.h:169
HttpRequestMethod method
Definition: MemObject.h:147
int64_t availableForSwapOut() const
buffered bytes we have not swapped out yet
Definition: MemObject.cc:489
HttpRequestPointer request
Definition: MemObject.h:212
void trimSwappable()
Definition: MemObject.cc:371
int64_t policyLowestOffsetToKeep(bool swap) const
Definition: MemObject.cc:348
int64_t objectBytesOnDisk() const
Definition: MemObject.cc:322
static constexpr Io ioUndecided
Definition: MemObject.h:173
HttpReplyPointer reply_
Definition: MemObject.h:234
void setNoDelay(bool const newValue)
Definition: MemObject.cc:431
void reset()
Definition: MemObject.cc:264
void trimUnSwappable()
Definition: MemObject.cc:396
void addClient(store_client *)
Definition: MemObject.cc:303
XitTable xitTable
current [shared] memory caching state for the entry
Definition: MemObject.h:199
int64_t expectedReplySize() const
Definition: MemObject.cc:238
SBuf vary_headers
Definition: MemObject.h:228
dlink_list clients
Definition: MemObject.h:150
static constexpr Io ioWriting
Definition: MemObject.h:175
const HttpReplyPointer & updatedReply() const
Definition: MemObject.h:64
String logUri_
URI used for logging (usually request URI)
Definition: MemObject.h:238
mem_hdr data_hdr
Definition: MemObject.h:148
AsyncCallPointer abortCallback
used for notifying StoreEntry writers about 3rd-party initiated aborts
Definition: MemObject.h:219
void updateReply(const HttpReply &r)
(re)sets updated reply;
Definition: MemObject.h:85
void dump() const
Definition: MemObject.cc:149
const HttpReply & freshestReply() const
Definition: MemObject.h:68
struct timeval start_ping
Definition: MemObject.h:214
void markEndOfReplyHeaders()
sets baseReply().hdr_sz (i.e. written reply headers size) to endOffset()
Definition: MemObject.cc:220
bool clientIsFirst(void *sc) const
Definition: MemObject.h:154
MEMPROXY_CLASS(MemObject)
void delayRead(const AsyncCallPointer &)
Definition: MemObject.cc:445
void write(const StoreIOBuffer &buf)
Definition: MemObject.cc:136
int64_t inmem_lo
Definition: MemObject.h:149
size_t swap_hdr_sz
Definition: MemObject.h:223
int mostBytesWanted(int max, bool ignoreDelayPools) const
Definition: MemObject.cc:415
static constexpr Io ioReading
Definition: MemObject.h:174
MemCache memCache
current [shared] memory caching state for the entry
Definition: MemObject.h:210
int64_t endOffset() const
Definition: MemObject.cc:214
void setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod)
Definition: MemObject.cc:76
const char * storeId() const
Definition: MemObject.cc:53
const HttpReply & baseReply() const
Definition: MemObject.h:60
HttpReply & adjustableBaseReply()
Definition: MemObject.cc:121
void unlinkRequest()
Definition: MemObject.h:56
bool hasUris() const
whether setUris() has been called
Definition: MemObject.cc:70
const char * logUri() const
client request URI used for logging; storeId() by default
Definition: MemObject.cc:64
DelayedAsyncCalls deferredReads
Definition: MemObject.h:240
HttpReplyPointer updatedReply_
Definition: MemObject.h:235
void kickReads()
Definition: MemObject.cc:459
PeerSelector * ircb_data
Definition: MemObject.h:216
bool readAheadPolicyCanRead() const
Definition: MemObject.cc:288
bool isContiguous() const
Definition: MemObject.cc:406
void stat(MemBuf *mb) const
Definition: MemObject.cc:189
int64_t object_sz
Definition: MemObject.h:222
Definition: SBuf.h:94
Definition: stmem.h:20
A const & max(A const &lhs, A const &rhs)
IoStatus
cache "I/O" direction and status
Definition: forward.h:40
@ ioReading
Definition: forward.h:40
@ ioWriting
Definition: forward.h:40
@ ioUndecided
Definition: forward.h:40
@ ioDone
Definition: forward.h:40
static int sc[16]
Definition: smbdes.c:121
void IRCB(CachePeer *, peer_t, AnyP::ProtocolType, void *, void *data)
Definition: typedefs.h:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors