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 "base/forward.h"
13 #include "dlink.h"
14 #include "StoreIOBuffer.h"
15 #include "StoreIOState.h"
16 
17 typedef void STCB(void *, StoreIOBuffer); /* store callback */
18 
19 class StoreEntry;
20 class ACLFilledChecklist;
21 class LogTags;
22 
25 {
26 
27 public:
28  virtual ~StoreClient () {}
29 
31  virtual LogTags *loggingTags() const = 0;
32 
33 protected:
35  virtual void fillChecklist(ACLFilledChecklist &) const = 0;
36 
40  bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const;
41 
42  // These methods only interpret Squid configuration. Their allowances are
43  // provisional -- other factors may prevent collapsed forwarding. The first
44  // two exist primarily to distinguish two major CF cases in callers code.
46  bool mayInitiateCollapsing() const { return onCollapsingPath(); }
48  bool onCollapsingPath() const;
49 };
50 
51 #if USE_DELAY_POOLS
52 #include "DelayId.h"
53 #endif
54 
55 /* keep track each client receiving data from that particular StoreEntry */
56 
58 {
60 
61 public:
63  ~store_client();
64  bool memReaderHasLowerOffset(int64_t) const;
65  int getType() const;
66  void fail();
67  void callback(ssize_t len, bool error = false);
68  void doCopy (StoreEntry *e);
69  void readHeader(const char *buf, ssize_t len);
70  void readBody(const char *buf, ssize_t len);
71  void copy(StoreEntry *, StoreIOBuffer, STCB *, void *);
72  void dumpStats(MemBuf * output, int clientNumber) const;
73 
74  int64_t cmp_offset;
75 #if STORE_CLIENT_LIST_DEBUG
76 
77  void *owner;
78 #endif
79 
80  StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
82 
83  struct {
87  } flags;
88 
89 #if USE_DELAY_POOLS
91  void setDelayId(DelayId delay_id);
92 #endif
93 
95  /* Below here is private - do no alter outside storeClient calls */
97 
98 private:
99  bool moreToSend() const;
100 
101  void fileRead();
102  void scheduleDiskRead();
103  void scheduleMemRead();
104  void scheduleRead();
105  bool startSwapin();
106  bool unpackHeader(char const *buf, ssize_t len);
107 
108  int type;
109  bool object_ok;
110 
111  /* Until we finish stuffing code into store_client */
112 
113 public:
114 
115  struct Callback {
117 
118  Callback (STCB *, void *);
119  bool pending() const;
124 };
125 
129 int storeUnregister(store_client * sc, StoreEntry * e, void *data);
130 int storePendingNClients(const StoreEntry * e);
131 int storeClientIsThisAClient(store_client * sc, void *someClient);
132 
133 #endif /* SQUID_STORECLIENT_H */
134 
struct store_client::Callback _callback
int storeClientIsThisAClient(store_client *sc, void *someClient)
StoreEntry * entry
Definition: StoreClient.h:80
void readHeader(const char *buf, ssize_t len)
virtual ~StoreClient()
Definition: StoreClient.h:28
virtual void fillChecklist(ACLFilledChecklist &) const =0
configure the ACL checklist with the current transaction state
Definition: store_client.cc:88
bool disk_io_pending
Definition: StoreClient.h:84
void error(char *format,...)
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
int storePendingNClients(const StoreEntry *e)
bool store_copying
Definition: StoreClient.h:85
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:25
void scheduleDiskRead()
#define NULL
Definition: types.h:166
CodeContextPointer codeContext
Store client context.
Definition: StoreClient.h:122
store_client(StoreEntry *)
struct store_client::@148 flags
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition: StoreClient.h:46
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
bool memReaderHasLowerOffset(int64_t) const
Definition: store_client.cc:97
Definition: MemBuf.h:24
bool onCollapsingPath() const
whether Squid configuration allows collapsing for this transaction
Definition: store_client.cc:52
void const char HLPCB void * data
Definition: stub_helper.cc:16
void readBody(const char *buf, ssize_t len)
virtual LogTags * loggingTags() const =0
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:90
StoreIOBuffer copyInto
Definition: StoreClient.h:96
StoreIOState::Pointer swapin_sio
Definition: StoreClient.h:81
int getType() const
int64_t cmp_offset
Definition: StoreClient.h:74
dlink_node node
Definition: StoreClient.h:94
void callback(ssize_t len, bool error=false)
void dumpStats(MemBuf *output, int clientNumber) const
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
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:86
void scheduleRead()
void const char * buf
Definition: stub_helper.cc:16
void STCB(void *, StoreIOBuffer)
Definition: StoreClient.h:17

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors