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 "RemovalPolicy.h"
16#include "SquidString.h"
17#include "stmem.h"
18#include "store/forward.h"
19#include "StoreIOBuffer.h"
20#include "StoreIOState.h"
21#include "typedefs.h" //for IRCB
22
23#if USE_DELAY_POOLS
24#include "DelayId.h"
25#endif
26
27typedef void STMCB (void *data, StoreIOBuffer wroteBuffer);
28
29class store_client;
30class PeerSelector;
31
33{
35
36public:
37 static size_t inUseCount();
38
39 void dump() const;
40 MemObject();
41 ~MemObject();
42
49 void setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod);
50
52 bool hasUris() const;
53
54 void write(const StoreIOBuffer &buf);
55 void unlinkRequest() { request = nullptr; }
56
59 const HttpReply &baseReply() const { return *reply_; }
60
63 const HttpReplyPointer &updatedReply() const { return updatedReply_; }
64
67 const HttpReply &freshestReply() const {
68 if (updatedReply_)
69 return *updatedReply_;
70 else
71 return baseReply();
72 }
73
78
82
84 void updateReply(const HttpReply &r) { updatedReply_ = &r; }
85
89 bool appliedUpdates = false;
90
91 void stat (MemBuf * mb) const;
92 int64_t endOffset () const;
93
96
99 int64_t expectedReplySize() const;
100 int64_t size() const;
101 void reset();
102 int64_t lowestMemReaderOffset() const;
103 bool readAheadPolicyCanRead() const;
104 void addClient(store_client *);
105 /* XXX belongs in MemObject::swapout, once swaphdrsz is managed
106 * better
107 */
108 int64_t objectBytesOnDisk() const;
109 int64_t policyLowestOffsetToKeep(bool swap) const;
110 int64_t availableForSwapOut() const;
111 void trimSwappable();
112 void trimUnSwappable();
113 bool isContiguous() const;
114 int mostBytesWanted(int max, bool ignoreDelayPools) const;
115 void setNoDelay(bool const newValue);
116#if USE_DELAY_POOLS
118#endif
119
120#if URL_CHECKSUM_DEBUG
121
122 void checkUrlChecksum() const;
123#endif
124
128 const char *urlXXX() const { return storeId(); }
129
132 const char *storeId() const;
133
135 const char *logUri() const;
136
139 int64_t inmem_lo = 0;
141
142 size_t clientCount() const {return nclients;}
143
144 bool clientIsFirst(void *sc) const {return (clients.head && sc == clients.head->data);}
145
146 int nclients = 0;
147
149 {
150 public:
151 int64_t queue_offset = 0;
153
155 typedef enum { swNeedsCheck = 0, swImpossible = -1, swPossible = +1, swStarted } Decision;
157 };
158
160
161 /* TODO: Remove this change-minimizing hack */
164 static constexpr Io ioReading = Store::ioReading;
165 static constexpr Io ioWriting = Store::ioWriting;
166 static constexpr Io ioDone = Store::ioDone;
167
170 {
171 public:
173 void open(const int32_t anIndex, const Io anIo)
174 {
175 index = anIndex;
176 io = anIo;
177 }
178
180 void close()
181 {
182 index = -1;
184 }
185
186 int32_t index = -1;
188 };
190
193 {
194 public:
195 int32_t index = -1;
196 int64_t offset = 0;
197
199 };
201
203
204 struct timeval start_ping;
207
211 int id = 0;
212 int64_t object_sz = -1;
213 size_t swap_hdr_sz = 0;
214#if URL_CHECKSUM_DEBUG
215 unsigned int chksum = 0;
216#endif
217
219
220 void delayRead(const AsyncCallPointer &);
221 void kickReads();
222
223private:
226
227 mutable String storeId_;
228 mutable String logUri_;
229
231};
232
235
236#endif /* SQUID_MEMOBJECT_H */
237
RemovalPolicy * mem_policy
Definition: MemObject.cc:44
void STMCB(void *data, StoreIOBuffer wroteBuffer)
Definition: MemObject.h:27
Definition: MemBuf.h:24
State of an entry with regards to the [shared] memory caching.
Definition: MemObject.h:193
int32_t index
entry position inside the memory cache
Definition: MemObject.h:195
Io io
current I/O state
Definition: MemObject.h:198
int64_t offset
bytes written/read to/from the memory cache so far
Definition: MemObject.h:196
int64_t queue_offset
number of bytes sent to SwapDir for writing
Definition: MemObject.h:151
Decision decision
current decision state
Definition: MemObject.h:156
StoreIOState::Pointer sio
Definition: MemObject.h:152
Decision
Decision states for StoreEntry::swapoutPossible() and related code.
Definition: MemObject.h:155
State of an entry with regards to the [shared] in-transit table.
Definition: MemObject.h:170
void close()
stop associating our StoreEntry with a Transients entry
Definition: MemObject.h:180
int32_t index
entry position inside the in-transit table
Definition: MemObject.h:186
Io io
current I/O state
Definition: MemObject.h:187
void open(const int32_t anIndex, const Io anIo)
associate our StoreEntry with a Transients entry at the given index
Definition: MemObject.h:173
void replaceBaseReply(const HttpReplyPointer &r)
Definition: MemObject.cc:128
String storeId_
StoreId for our entry (usually request URI)
Definition: MemObject.h:227
bool appliedUpdates
Definition: MemObject.h:89
static constexpr Io ioDone
Definition: MemObject.h:166
RemovalPolicyNode repl
Definition: MemObject.h:210
int64_t lowestMemReaderOffset() const
Definition: MemObject.cc:277
DelayId mostBytesAllowed() const
Definition: MemObject.cc:460
IRCB * ping_reply_callback
Definition: MemObject.h:205
int64_t size() const
Definition: MemObject.cc:229
size_t clientCount() const
Definition: MemObject.h:142
const char * urlXXX() const
Definition: MemObject.h:128
int nclients
Definition: MemObject.h:146
static size_t inUseCount()
Definition: MemObject.cc:47
SwapOut swapout
Definition: MemObject.h:159
HttpRequestMethod method
Definition: MemObject.h:137
int64_t availableForSwapOut() const
buffered bytes we have not swapped out yet
Definition: MemObject.cc:483
HttpRequestPointer request
Definition: MemObject.h:202
void trimSwappable()
Definition: MemObject.cc:365
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:163
HttpReplyPointer reply_
Definition: MemObject.h:224
void setNoDelay(bool const newValue)
Definition: MemObject.cc:425
void reset()
Definition: MemObject.cc:264
void trimUnSwappable()
Definition: MemObject.cc:390
void addClient(store_client *)
Definition: MemObject.cc:303
XitTable xitTable
current [shared] memory caching state for the entry
Definition: MemObject.h:189
int64_t expectedReplySize() const
Definition: MemObject.cc:238
SBuf vary_headers
Definition: MemObject.h:218
dlink_list clients
Definition: MemObject.h:140
static constexpr Io ioWriting
Definition: MemObject.h:165
const HttpReplyPointer & updatedReply() const
Definition: MemObject.h:63
String logUri_
URI used for logging (usually request URI)
Definition: MemObject.h:228
mem_hdr data_hdr
Definition: MemObject.h:138
AsyncCallPointer abortCallback
used for notifying StoreEntry writers about 3rd-party initiated aborts
Definition: MemObject.h:209
void updateReply(const HttpReply &r)
(re)sets updated reply;
Definition: MemObject.h:84
void dump() const
Definition: MemObject.cc:149
const HttpReply & freshestReply() const
Definition: MemObject.h:67
struct timeval start_ping
Definition: MemObject.h:204
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:144
MEMPROXY_CLASS(MemObject)
void delayRead(const AsyncCallPointer &)
Definition: MemObject.cc:439
void write(const StoreIOBuffer &buf)
Definition: MemObject.cc:136
int64_t inmem_lo
Definition: MemObject.h:139
size_t swap_hdr_sz
Definition: MemObject.h:213
int mostBytesWanted(int max, bool ignoreDelayPools) const
Definition: MemObject.cc:409
static constexpr Io ioReading
Definition: MemObject.h:164
MemCache memCache
current [shared] memory caching state for the entry
Definition: MemObject.h:200
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:59
HttpReply & adjustableBaseReply()
Definition: MemObject.cc:121
void unlinkRequest()
Definition: MemObject.h:55
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:230
HttpReplyPointer updatedReply_
Definition: MemObject.h:225
void kickReads()
Definition: MemObject.cc:453
PeerSelector * ircb_data
Definition: MemObject.h:206
bool readAheadPolicyCanRead() const
Definition: MemObject.cc:288
bool isContiguous() const
Definition: MemObject.cc:400
void stat(MemBuf *mb) const
Definition: MemObject.cc:189
int64_t object_sz
Definition: MemObject.h:212
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