MemObject.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
12 #include "CommRead.h"
13 #include "dlink.h"
14 #include "http/RequestMethod.h"
15 #include "RemovalPolicy.h"
16 #include "SquidString.h"
17 #include "stmem.h"
18 #include "StoreIOBuffer.h"
19 #include "StoreIOState.h"
20 #include "typedefs.h" //for IRCB
21 
22 #if USE_DELAY_POOLS
23 #include "DelayId.h"
24 #endif
25 
26 typedef void STMCB (void *data, StoreIOBuffer wroteBuffer);
27 typedef void STABH(void *);
28 
29 class store_client;
30 
31 class MemObject
32 {
34 
35 public:
36  static size_t inUseCount();
37 
38  void dump() const;
39  MemObject();
40  ~MemObject();
41 
48  void setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod);
49 
51  bool hasUris() const;
52 
53  void write(const StoreIOBuffer &buf);
54  void unlinkRequest() { request = nullptr; }
55  const HttpReplyPointer &getReply() const { return reply_; }
56  void replaceReply(const HttpReplyPointer &r) { reply_ = r; }
57  void stat (MemBuf * mb) const;
58  int64_t endOffset () const;
59  void markEndOfReplyHeaders();
60  int64_t expectedReplySize() const;
63  int64_t size() const;
64  void reset();
65  int64_t lowestMemReaderOffset() const;
66  bool readAheadPolicyCanRead() const;
67  void addClient(store_client *);
68  /* XXX belongs in MemObject::swapout, once swaphdrsz is managed
69  * better
70  */
71  int64_t objectBytesOnDisk() const;
72  int64_t policyLowestOffsetToKeep(bool swap) const;
73  int64_t availableForSwapOut() const;
74  void trimSwappable();
75  void trimUnSwappable();
76  bool isContiguous() const;
77  int mostBytesWanted(int max, bool ignoreDelayPools) const;
78  void setNoDelay(bool const newValue);
79 #if USE_DELAY_POOLS
80  DelayId mostBytesAllowed() const;
81 #endif
82 
83 #if URL_CHECKSUM_DEBUG
84 
85  void checkUrlChecksum() const;
86 #endif
87 
91  const char *urlXXX() const { return storeId(); }
92 
95  const char *storeId() const;
96 
98  const char *logUri() const;
99 
102  int64_t inmem_lo;
104 
105  size_t clientCount() const {return nclients;}
106 
107  bool clientIsFirst(void *sc) const {return (clients.head && sc == clients.head->data);}
108 
109  int nclients;
110 
111  class SwapOut
112  {
113  public:
115 
116  int64_t queue_offset;
118 
120  typedef enum { swNeedsCheck = 0, swImpossible = -1, swPossible = +1, swStarted } Decision;
122  };
123 
125 
127  typedef enum { ioUndecided, ioWriting, ioReading, ioDone } Io;
128 
130  class XitTable
131  {
132  public:
134 
135  int32_t index;
136  Io io;
137  };
139 
141  class MemCache
142  {
143  public:
145 
146  int32_t index;
147  int64_t offset;
148 
149  Io io;
150  };
152 
154 
155  /* Read only - this reply must be preserved by store clients */
156  /* The original reply. possibly with updated metadata. */
158 
159  struct timeval start_ping;
161  void *ircb_data;
162 
163  struct {
165  void *data;
166  } abort;
168  int id;
169  int64_t object_sz;
170  size_t swap_hdr_sz;
171 #if URL_CHECKSUM_DEBUG
172 
173  unsigned int chksum;
174 #endif
175 
177 
178  void delayRead(DeferredRead const &);
179  void kickReads();
180 
181 private:
183 
184  mutable String storeId_;
185  mutable String logUri_;
186 
188 };
189 
191 extern RemovalPolicy *mem_policy;
192 
193 #endif /* SQUID_MEMOBJECT_H */
194 
void replaceReply(const HttpReplyPointer &r)
Definition: MemObject.h:56
MEMPROXY_CLASS(MemObject)
Io io
current I/O state
Definition: MemObject.h:136
RemovalPolicyNode repl
Definition: MemObject.h:167
Decision decision
current decision state
Definition: MemObject.h:121
void kickReads()
Definition: MemObject.cc:456
static int sc[16]
Definition: smbdes.c:121
int64_t size() const
Definition: MemObject.cc:247
String storeId_
StoreId for our entry (usually request URI)
Definition: MemObject.h:184
size_t swap_hdr_sz
Definition: MemObject.h:170
void unlinkRequest()
Definition: MemObject.h:54
Definition: SBuf.h:87
STABH * callback
Definition: MemObject.h:164
int64_t endOffset() const
Definition: MemObject.cc:232
void setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod)
Definition: MemObject.cc:77
Io io
current I/O state
Definition: MemObject.h:149
DeferredReadManager deferredReads
Definition: MemObject.h:187
bool clientIsFirst(void *sc) const
Definition: MemObject.h:107
static size_t inUseCount()
Definition: MemObject.cc:48
Definition: stmem.h:19
struct MemObject::@86 abort
const char * logUri() const
client request URI used for logging; storeId() by default
Definition: MemObject.cc:65
struct timeval start_ping
Definition: MemObject.h:159
void * ircb_data
Definition: MemObject.h:161
A const & max(A const &lhs, A const &rhs)
MemCache memCache
current [shared] memory caching state for the entry
Definition: MemObject.h:151
XitTable xitTable
current [shared] memory caching state for the entry
Definition: MemObject.h:138
void trimUnSwappable()
Definition: MemObject.cc:396
int32_t index
entry position inside the memory cache
Definition: MemObject.h:146
int64_t lowestMemReaderOffset() const
Definition: MemObject.cc:284
StoreIOState::Pointer sio
Definition: MemObject.h:117
bool readAheadPolicyCanRead() const
Definition: MemObject.cc:295
int32_t index
entry position inside the in-transit table
Definition: MemObject.h:135
void const char HLPCB void * data
Definition: stub_helper.cc:16
void delayRead(DeferredRead const &)
Definition: MemObject.cc:442
void stat(MemBuf *mb) const
Definition: MemObject.cc:205
HttpReplyPointer reply_
Definition: MemObject.h:182
State of an entry with regards to the [shared] memory caching.
Definition: MemObject.h:141
int64_t object_sz
Definition: MemObject.h:169
const char * storeId() const
Definition: MemObject.cc:54
HttpRequestMethod method
Definition: MemObject.h:100
Io
cache "I/O" direction and status
Definition: MemObject.h:127
bool smpCollapsed
whether this entry gets data from another worker
Definition: MemObject.h:153
int64_t policyLowestOffsetToKeep(bool swap) const
Definition: MemObject.cc:354
void STMCB(void *data, StoreIOBuffer wroteBuffer)
Definition: MemObject.h:26
bool hasUris() const
whether setUris() has been called
Definition: MemObject.cc:71
int64_t objectBytesOnDisk() const
Definition: MemObject.cc:328
String logUri_
URI used for logging (usually request URI)
Definition: MemObject.h:185
void * data
Definition: MemObject.h:165
void markEndOfReplyHeaders()
Definition: MemObject.cc:238
DelayId mostBytesAllowed() const
Definition: MemObject.cc:463
void write(const StoreIOBuffer &buf)
Definition: MemObject.cc:148
RemovalPolicy * mem_policy
Definition: MemObject.cc:45
void IRCB(CachePeer *, peer_t, AnyP::ProtocolType, void *, void *data)
Definition: typedefs.h:22
void STABH(void *)
Definition: MemObject.h:27
void const char * buf
Definition: stub_helper.cc:16
int mostBytesWanted(int max, bool ignoreDelayPools) const
Definition: MemObject.cc:415
State of an entry with regards to the [shared] in-transit table.
Definition: MemObject.h:130
SwapOut swapout
Definition: MemObject.h:124
SBuf vary_headers
Definition: MemObject.h:176
int64_t queue_offset
number of bytes sent to SwapDir for writing
Definition: MemObject.h:116
void reset()
Definition: MemObject.cc:273
dlink_list clients
Definition: MemObject.h:103
Definition: MemBuf.h:23
int nclients
Definition: MemObject.h:109
Decision
Decision states for StoreEntry::swapoutPossible() and related code.
Definition: MemObject.h:120
const HttpReplyPointer & getReply() const
Definition: MemObject.h:55
void dump() const
Definition: MemObject.cc:163
size_t clientCount() const
Definition: MemObject.h:105
mem_hdr data_hdr
Definition: MemObject.h:101
void trimSwappable()
Definition: MemObject.cc:371
bool isContiguous() const
Definition: MemObject.cc:406
IRCB * ping_reply_callback
Definition: MemObject.h:160
int64_t availableForSwapOut() const
buffered bytes we have not swapped out yet
Definition: MemObject.cc:499
HttpRequestPointer request
Definition: MemObject.h:157
void setNoDelay(bool const newValue)
Definition: MemObject.cc:429
void addClient(store_client *)
Definition: MemObject.cc:309
int64_t expectedReplySize() const
Definition: MemObject.cc:256
const char * urlXXX() const
Definition: MemObject.h:91
int64_t inmem_lo
Definition: MemObject.h:102
int64_t offset
bytes written/read to/from the memory cache so far
Definition: MemObject.h:147

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors