StoreClient.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_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
19typedef void STCB(void *, StoreIOBuffer); /* store callback */
20
21class StoreEntry;
23class LogTags;
24
27{
28
29public:
30 ~StoreClient () override {}
31
33 virtual LogTags *loggingTags() const = 0;
34
35protected:
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
60public:
61 explicit store_client(StoreEntry *);
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
110
111#if USE_DELAY_POOLS
113
118 int bytesWanted() const;
119
120 void setDelayId(DelayId delay_id);
121#endif
122
124
125private:
126 bool moreToSend() const;
127
128 void fileRead();
129 void scheduleDiskRead();
130 void scheduleMemRead();
131 void scheduleRead();
132 bool startSwapin();
133
134 void fail();
135 void callback(ssize_t);
136 void noteCopiedBytes(size_t);
137 void noteEof();
138 void noteNews();
139 void finishCallback();
140 static void FinishCallback(store_client *);
141
142 int type;
144
148
152
153 /* Until we finish stuffing code into store_client */
154
155public:
156
157 struct Callback {
158 Callback ():callback_handler(nullptr), callback_data(nullptr) {}
159
160 Callback (STCB *, void *);
161
165 bool pending() const;
166
170
174};
175
178int storeUnregister(store_client * sc, StoreEntry * e, void *data);
179int storePendingNClients(const StoreEntry * e);
180int storeClientIsThisAClient(store_client * sc, void *someClient);
181
182#endif /* SQUID_STORECLIENT_H */
183
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
int storeClientIsThisAClient(store_client *sc, void *someClient)
int storePendingNClients(const StoreEntry *e)
void STCB(void *, StoreIOBuffer)
Definition: StoreClient.h:19
void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *)
store_client * storeClientListAdd(StoreEntry *e, void *data)
void error(char *format,...)
#define CBDATA_CLASS(type)
Definition: cbdata.h:289
an interface for those capable of configuring an ACLFilledChecklist object
Definition: MemBuf.h:24
a storeGetPublic*() caller
Definition: StoreClient.h:27
bool onCollapsingPath() const
whether Squid configuration allows collapsing for this transaction
Definition: store_client.cc:50
virtual LogTags * loggingTags() const =0
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition: StoreClient.h:45
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
Definition: store_client.cc:64
~StoreClient() override
Definition: StoreClient.h:30
int64_t offset
Definition: StoreIOBuffer.h:55
int64_t cmp_offset
Definition: StoreClient.h:91
int getType() const
Definition: store_client.cc:88
void readHeader(const char *buf, ssize_t len)
void setDelayId(DelayId delay_id)
void scheduleDiskRead()
bool startSwapin()
opens the swapin "file" if possible; otherwise, fail()s and returns false
bool moreToSend() const
Whether there is (or will be) more entry data for us.
void noteNews()
if necessary and possible, informs the Store reader about copy() result
void noteSwapInDone(bool error)
void scheduleRead()
void readBody(const char *buf, ssize_t len)
DelayId delayId
Definition: StoreClient.h:112
StoreEntry * entry
Definition: StoreClient.h:97
void copy(StoreEntry *, StoreIOBuffer, STCB *, void *)
int bytesWanted() const
void doCopy(StoreEntry *e)
void noteCopiedBytes(size_t)
bool store_copying
Definition: StoreClient.h:108
struct store_client::Callback _callback
StoreIOBuffer copyInto
Definition: StoreClient.h:147
void finishCallback()
finishes a copy()-STCB sequence by synchronously calling STCB
bool disk_io_pending
Definition: StoreClient.h:104
size_t copiedSize
Definition: StoreClient.h:151
store_client(StoreEntry *)
static void FinishCallback(store_client *)
finishCallback() wrapper; TODO: Add NullaryMemFunT for non-jobs.
dlink_node node
Definition: StoreClient.h:123
int64_t readOffset() const
Definition: StoreClient.h:72
void scheduleMemRead()
struct store_client::@141 flags
StoreIOState::Pointer swapin_sio
Definition: StoreClient.h:98
void dumpStats(MemBuf *output, int clientNumber) const
void callback(ssize_t)
static int sc[16]
Definition: smbdes.c:121
CodeContextPointer codeContext
Store client context.
Definition: StoreClient.h:169
AsyncCall::Pointer notifier
a scheduled asynchronous finishCallback() call (or nil)
Definition: StoreClient.h:172

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors