StoreClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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/forward.h"
14 #include "dlink.h"
15 #include "StoreIOBuffer.h"
16 #include "StoreIOState.h"
17 
18 typedef void STCB(void *, StoreIOBuffer); /* store callback */
19 
20 class StoreEntry;
21 class ACLFilledChecklist;
22 class LogTags;
23 
26 {
27 
28 public:
29  virtual ~StoreClient () {}
30 
32  virtual LogTags *loggingTags() const = 0;
33 
34 protected:
38  bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const;
39 
40  // These methods only interpret Squid configuration. Their allowances are
41  // provisional -- other factors may prevent collapsed forwarding. The first
42  // two exist primarily to distinguish two major CF cases in callers code.
44  bool mayInitiateCollapsing() const { return onCollapsingPath(); }
46  bool onCollapsingPath() const;
47 };
48 
49 #if USE_DELAY_POOLS
50 #include "DelayId.h"
51 #endif
52 
53 /* keep track each client receiving data from that particular StoreEntry */
54 
56 {
58 
59 public:
61  ~store_client();
62  bool memReaderHasLowerOffset(int64_t) const;
63  int getType() const;
64  void fail();
65  void callback(ssize_t len, bool error = false);
66  void doCopy (StoreEntry *e);
67  void readHeader(const char *buf, ssize_t len);
68  void readBody(const char *buf, ssize_t len);
69  void copy(StoreEntry *, StoreIOBuffer, STCB *, void *);
70  void dumpStats(MemBuf * output, int clientNumber) const;
71 
72  int64_t cmp_offset;
73 #if STORE_CLIENT_LIST_DEBUG
74 
75  void *owner;
76 #endif
77 
78  StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
80 
81  struct {
85  } flags;
86 
87 #if USE_DELAY_POOLS
89  void setDelayId(DelayId delay_id);
90 #endif
91 
93  /* Below here is private - do no alter outside storeClient calls */
95 
96 private:
97  bool moreToSend() const;
98 
99  void fileRead();
100  void scheduleDiskRead();
101  void scheduleMemRead();
102  void scheduleRead();
103  bool startSwapin();
104  bool unpackHeader(char const *buf, ssize_t len);
105 
106  int type;
107  bool object_ok;
108 
109  /* Until we finish stuffing code into store_client */
110 
111 public:
112 
113  struct Callback {
115 
116  Callback (STCB *, void *);
117  bool pending() const;
122 };
123 
125 store_client* storeClientListAdd(StoreEntry * e, void *data);
126 int storeClientCopyPending(store_client *, StoreEntry * e, void *data);
127 int storeUnregister(store_client * sc, StoreEntry * e, void *data);
128 int storePendingNClients(const StoreEntry * e);
129 int storeClientIsThisAClient(store_client * sc, void *someClient);
130 
131 #endif /* SQUID_STORECLIENT_H */
132 
struct store_client::Callback _callback
int storeClientIsThisAClient(store_client *sc, void *someClient)
StoreEntry * entry
Definition: StoreClient.h:78
void readHeader(const char *buf, ssize_t len)
virtual ~StoreClient()
Definition: StoreClient.h:29
bool disk_io_pending
Definition: StoreClient.h:82
void error(char *format,...)
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
int storePendingNClients(const StoreEntry *e)
bool store_copying
Definition: StoreClient.h:83
void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *)
bool moreToSend() const
Whether there is (or will be) more entry data for us.
void scheduleMemRead()
a storeGetPublic*() caller
Definition: StoreClient.h:26
void scheduleDiskRead()
#define NULL
Definition: types.h:166
CodeContextPointer codeContext
Store client context.
Definition: StoreClient.h:120
store_client(StoreEntry *)
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition: StoreClient.h:44
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
bool memReaderHasLowerOffset(int64_t) const
Definition: store_client.cc:90
Definition: MemBuf.h:24
bool onCollapsingPath() const
whether Squid configuration allows collapsing for this transaction
Definition: store_client.cc:52
void readBody(const char *buf, ssize_t len)
virtual LogTags * loggingTags() const =0
struct store_client::@146 flags
int storeClientCopyPending(store_client *, StoreEntry *e, void *data)
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:66
DelayId delayId
Definition: StoreClient.h:88
StoreIOBuffer copyInto
Definition: StoreClient.h:94
StoreIOState::Pointer swapin_sio
Definition: StoreClient.h:79
int getType() const
Definition: store_client.cc:96
int64_t cmp_offset
Definition: StoreClient.h:72
dlink_node node
Definition: StoreClient.h:92
void callback(ssize_t len, bool error=false)
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)
void setDelayId(DelayId delay_id)
void doCopy(StoreEntry *e)
bool copy_event_pending
Definition: StoreClient.h:84
an interface for those capable of configuring an ACLFilledChecklist object
void scheduleRead()
void STCB(void *, StoreIOBuffer)
Definition: StoreClient.h:18

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors