MemObject.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 "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 
27 typedef void STMCB (void *data, StoreIOBuffer wroteBuffer);
28 typedef void STABH(void *);
29 
30 class store_client;
31 
32 class MemObject
33 {
35 
36 public:
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  const HttpReplyPointer &getReply() const { return reply_; }
57  void replaceReply(const HttpReplyPointer &r) { reply_ = r; }
58  void stat (MemBuf * mb) const;
59  int64_t endOffset () const;
60  void markEndOfReplyHeaders();
61  int64_t expectedReplySize() const;
64  int64_t size() const;
65  void reset();
66  int64_t lowestMemReaderOffset() const;
67  bool readAheadPolicyCanRead() const;
68  void addClient(store_client *);
69  /* XXX belongs in MemObject::swapout, once swaphdrsz is managed
70  * better
71  */
72  int64_t objectBytesOnDisk() const;
73  int64_t policyLowestOffsetToKeep(bool swap) const;
74  int64_t availableForSwapOut() const;
75  void trimSwappable();
76  void trimUnSwappable();
77  bool isContiguous() const;
78  int mostBytesWanted(int max, bool ignoreDelayPools) const;
79  void setNoDelay(bool const newValue);
80 #if USE_DELAY_POOLS
81  DelayId mostBytesAllowed() const;
82 #endif
83 
84 #if URL_CHECKSUM_DEBUG
85 
86  void checkUrlChecksum() const;
87 #endif
88 
92  const char *urlXXX() const { return storeId(); }
93 
96  const char *storeId() const;
97 
99  const char *logUri() const;
100 
103  int64_t inmem_lo;
105 
106  size_t clientCount() const {return nclients;}
107 
108  bool clientIsFirst(void *sc) const {return (clients.head && sc == clients.head->data);}
109 
110  int nclients;
111 
112  class SwapOut
113  {
114  public:
116 
117  int64_t queue_offset;
119 
121  typedef enum { swNeedsCheck = 0, swImpossible = -1, swPossible = +1, swStarted } Decision;
123  };
124 
126 
127  /* TODO: Remove this change-minimizing hack */
129  static constexpr Io ioUndecided = Store::ioUndecided;
130  static constexpr Io ioReading = Store::ioReading;
131  static constexpr Io ioWriting = Store::ioWriting;
132  static constexpr Io ioDone = Store::ioDone;
133 
135  class XitTable
136  {
137  public:
139 
140  int32_t index;
141  Io io;
142  };
144 
146  class MemCache
147  {
148  public:
150 
151  int32_t index;
152  int64_t offset;
153 
154  Io io;
155  };
157 
158  /* Read only - this reply must be preserved by store clients */
159  /* The original reply. possibly with updated metadata. */
161 
162  struct timeval start_ping;
164  void *ircb_data;
165 
166  struct {
168  void *data;
169  } abort;
171  int id;
172  int64_t object_sz;
173  size_t swap_hdr_sz;
174 #if URL_CHECKSUM_DEBUG
175 
176  unsigned int chksum;
177 #endif
178 
180 
181  void delayRead(DeferredRead const &);
182  void kickReads();
183 
184 private:
186 
187  mutable String storeId_;
188  mutable String logUri_;
189 
191 };
192 
194 extern RemovalPolicy *mem_policy;
195 
196 #endif /* SQUID_MEMOBJECT_H */
197 
void replaceReply(const HttpReplyPointer &r)
Definition: MemObject.h:57
Io io
current I/O state
Definition: MemObject.h:141
RemovalPolicyNode repl
Definition: MemObject.h:170
Decision decision
current decision state
Definition: MemObject.h:122
void kickReads()
Definition: MemObject.cc:453
static int sc[16]
Definition: smbdes.c:121
int64_t size() const
Definition: MemObject.cc:244
#define MEMPROXY_CLASS(CLASS)
String storeId_
StoreId for our entry (usually request URI)
Definition: MemObject.h:187
size_t swap_hdr_sz
Definition: MemObject.h:173
void unlinkRequest()
Definition: MemObject.h:55
Definition: SBuf.h:86
STABH * callback
Definition: MemObject.h:167
static constexpr Io ioWriting
Definition: MemObject.h:131
int64_t endOffset() const
Definition: MemObject.cc:229
void setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod)
Definition: MemObject.cc:77
Io io
current I/O state
Definition: MemObject.h:154
DeferredReadManager deferredReads
Definition: MemObject.h:190
bool clientIsFirst(void *sc) const
Definition: MemObject.h:108
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:162
void * ircb_data
Definition: MemObject.h:164
A const & max(A const &lhs, A const &rhs)
MemCache memCache
current [shared] memory caching state for the entry
Definition: MemObject.h:156
XitTable xitTable
current [shared] memory caching state for the entry
Definition: MemObject.h:143
void trimUnSwappable()
Definition: MemObject.cc:393
static constexpr Io ioUndecided
Definition: MemObject.h:129
int32_t index
entry position inside the memory cache
Definition: MemObject.h:151
int64_t lowestMemReaderOffset() const
Definition: MemObject.cc:281
StoreIOState::Pointer sio
Definition: MemObject.h:118
bool readAheadPolicyCanRead() const
Definition: MemObject.cc:292
int32_t index
entry position inside the in-transit table
Definition: MemObject.h:140
void const char HLPCB void * data
Definition: stub_helper.cc:16
void delayRead(DeferredRead const &)
Definition: MemObject.cc:439
void stat(MemBuf *mb) const
Definition: MemObject.cc:204
HttpReplyPointer reply_
Definition: MemObject.h:185
State of an entry with regards to the [shared] memory caching.
Definition: MemObject.h:146
int64_t object_sz
Definition: MemObject.h:172
const char * storeId() const
Definition: MemObject.cc:54
HttpRequestMethod method
Definition: MemObject.h:101
IoStatus
cache "I/O" direction and status
Definition: forward.h:40
int64_t policyLowestOffsetToKeep(bool swap) const
Definition: MemObject.cc:351
void STMCB(void *data, StoreIOBuffer wroteBuffer)
Definition: MemObject.h:27
bool hasUris() const
whether setUris() has been called
Definition: MemObject.cc:71
int64_t objectBytesOnDisk() const
Definition: MemObject.cc:325
String logUri_
URI used for logging (usually request URI)
Definition: MemObject.h:188
void * data
Definition: MemObject.h:168
void markEndOfReplyHeaders()
Definition: MemObject.cc:235
DelayId mostBytesAllowed() const
Definition: MemObject.cc:460
void write(const StoreIOBuffer &buf)
Definition: MemObject.cc:147
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:28
void const char * buf
Definition: stub_helper.cc:16
int mostBytesWanted(int max, bool ignoreDelayPools) const
Definition: MemObject.cc:412
State of an entry with regards to the [shared] in-transit table.
Definition: MemObject.h:135
SwapOut swapout
Definition: MemObject.h:125
SBuf vary_headers
Definition: MemObject.h:179
int64_t queue_offset
number of bytes sent to SwapDir for writing
Definition: MemObject.h:117
void reset()
Definition: MemObject.cc:270
dlink_list clients
Definition: MemObject.h:104
Definition: MemBuf.h:23
int nclients
Definition: MemObject.h:110
Decision
Decision states for StoreEntry::swapoutPossible() and related code.
Definition: MemObject.h:121
const HttpReplyPointer & getReply() const
Definition: MemObject.h:56
void dump() const
Definition: MemObject.cc:162
size_t clientCount() const
Definition: MemObject.h:106
mem_hdr data_hdr
Definition: MemObject.h:102
static constexpr Io ioDone
Definition: MemObject.h:132
static constexpr Io ioReading
Definition: MemObject.h:130
void trimSwappable()
Definition: MemObject.cc:368
bool isContiguous() const
Definition: MemObject.cc:403
IRCB * ping_reply_callback
Definition: MemObject.h:163
int64_t availableForSwapOut() const
buffered bytes we have not swapped out yet
Definition: MemObject.cc:496
HttpRequestPointer request
Definition: MemObject.h:160
void setNoDelay(bool const newValue)
Definition: MemObject.cc:426
void addClient(store_client *)
Definition: MemObject.cc:306
int64_t expectedReplySize() const
Definition: MemObject.cc:253
const char * urlXXX() const
Definition: MemObject.h:92
int64_t inmem_lo
Definition: MemObject.h:103
int64_t offset
bytes written/read to/from the memory cache so far
Definition: MemObject.h:152

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors