StoreClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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_STORECLIENT_H
10 #define SQUID_STORECLIENT_H
11 
12 #include "acl/ChecklistFiller.h"
13 #include "base/AsyncCall.h"
14 #include "base/forward.h"
15 #include "dlink.h"
16 #include "StoreIOBuffer.h"
17 #include "StoreIOState.h"
18 
19 typedef void STCB(void *, StoreIOBuffer); /* store callback */
20 
21 class StoreEntry;
22 class ACLFilledChecklist;
23 class LogTags;
24 
27 {
28 
29 public:
30  virtual ~StoreClient () {}
31 
33  virtual LogTags *loggingTags() const = 0;
34 
35 protected:
39  bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const;
40 
41  // These methods only interpret Squid configuration. Their allowances are
42  // provisional -- other factors may prevent collapsed forwarding. The first
43  // two exist primarily to distinguish two major CF cases in callers code.
45  bool mayInitiateCollapsing() const { return onCollapsingPath(); }
47  bool onCollapsingPath() const;
48 };
49 
50 #if USE_DELAY_POOLS
51 #include "DelayId.h"
52 #endif
53 
54 /* keep track each client receiving data from that particular StoreEntry */
55 
57 {
59 
60 public:
62  ~store_client();
63 
70  // TODO: Callers do not expect negative offset. Verify that the return
71  // value cannot be negative and convert to unsigned in this case.
72  int64_t readOffset() const { return copyInto.offset; }
73 
74  int getType() const;
75 
79  void noteSwapInDone(bool error);
80 
81  void doCopy (StoreEntry *e);
82  void readHeader(const char *buf, ssize_t len);
83  void readBody(const char *buf, ssize_t len);
84 
87  void copy(StoreEntry *, StoreIOBuffer, STCB *, void *);
88 
89  void dumpStats(MemBuf * output, int clientNumber) const;
90 
91  int64_t cmp_offset;
92 #if STORE_CLIENT_LIST_DEBUG
93 
94  void *owner;
95 #endif
96 
97  StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
99 
100  struct {
103  // TODO: a better name reflecting the 'in' scope of the flag
105 
109  } flags;
110 
111 #if USE_DELAY_POOLS
113 
118  int bytesWanted() const;
119 
120  void setDelayId(DelayId delay_id);
121 #endif
122 
124 
125 private:
126  bool moreToSend() const;
127 
128  void fileRead();
129  void scheduleDiskRead();
130  void scheduleMemRead();
131  void scheduleRead();
132  bool startSwapin();
133  bool unpackHeader(char const *buf, ssize_t len);
134 
135  void fail();
136  void callback(ssize_t);
137  void noteCopiedBytes(size_t);
138  void noteEof();
139  void noteNews();
140  void finishCallback();
141  static void FinishCallback(store_client *);
142 
143  int type;
144  bool object_ok;
145 
149 
152  size_t copiedSize;
153 
154  /* Until we finish stuffing code into store_client */
155 
156 public:
157 
158  struct Callback {
160 
161  Callback (STCB *, void *);
162 
166  bool pending() const;
167 
171 
175 };
176 
178 store_client* storeClientListAdd(StoreEntry * e, void *data);
179 int storeClientCopyPending(store_client *, StoreEntry * e, void *data);
180 int storeUnregister(store_client * sc, StoreEntry * e, void *data);
181 int storePendingNClients(const StoreEntry * e);
182 int storeClientIsThisAClient(store_client * sc, void *someClient);
183 
184 #endif /* SQUID_STORECLIENT_H */
185 
static void FinishCallback(store_client *)
finishCallback() wrapper; TODO: Add NullaryMemFunT for non-jobs.
struct store_client::Callback _callback
int storeClientIsThisAClient(store_client *sc, void *someClient)
StoreEntry * entry
Definition: StoreClient.h:97
void readHeader(const char *buf, ssize_t len)
virtual ~StoreClient()
Definition: StoreClient.h:30
void noteSwapInDone(bool error)
void noteNews()
if necessary and possible, informs the Store reader about copy() result
void callback(ssize_t)
bool disk_io_pending
Definition: StoreClient.h:104
void error(char *format,...)
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
int64_t offset
Definition: StoreIOBuffer.h:55
int storePendingNClients(const StoreEntry *e)
void noteCopiedBytes(size_t)
bool store_copying
Definition: StoreClient.h:108
void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *)
bool moreToSend() const
Whether there is (or will be) more entry data for us.
void scheduleMemRead()
AsyncCall::Pointer notifier
a scheduled asynchronous finishCallback() call (or nil)
Definition: StoreClient.h:173
struct store_client::@145 flags
a storeGetPublic*() caller
Definition: StoreClient.h:27
int64_t readOffset() const
Definition: StoreClient.h:72
void scheduleDiskRead()
#define NULL
Definition: types.h:166
CodeContextPointer codeContext
Store client context.
Definition: StoreClient.h:170
store_client(StoreEntry *)
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition: StoreClient.h:45
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
Definition: MemBuf.h:24
bool onCollapsingPath() const
whether Squid configuration allows collapsing for this transaction
Definition: store_client.cc:51
void readBody(const char *buf, ssize_t len)
virtual LogTags * loggingTags() const =0
int storeClientCopyPending(store_client *, StoreEntry *e, void *data)
int bytesWanted() const
static int sc[16]
Definition: smbdes.c:121
store_client * storeClientListAdd(StoreEntry *e, void *data)
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
Definition: store_client.cc:65
DelayId delayId
Definition: StoreClient.h:112
StoreIOBuffer copyInto
Definition: StoreClient.h:148
StoreIOState::Pointer swapin_sio
Definition: StoreClient.h:98
int getType() const
Definition: store_client.cc:89
int64_t cmp_offset
Definition: StoreClient.h:91
dlink_node node
Definition: StoreClient.h:123
void dumpStats(MemBuf *output, int clientNumber) const
void copy(StoreEntry *, StoreIOBuffer, STCB *, void *)
bool startSwapin()
opens the swapin "file" if possible; otherwise, fail()s and returns false
bool unpackHeader(char const *buf, ssize_t len)
size_t copiedSize
Definition: StoreClient.h:152
void setDelayId(DelayId delay_id)
void doCopy(StoreEntry *e)
void finishCallback()
finishes a copy()-STCB sequence by synchronously calling STCB
an interface for those capable of configuring an ACLFilledChecklist object
void scheduleRead()
void STCB(void *, StoreIOBuffer)
Definition: StoreClient.h:19

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors