StoreClient.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_STORECLIENT_H
10 #define SQUID_STORECLIENT_H
11 
12 #include "dlink.h"
13 #include "StoreIOBuffer.h"
14 #include "StoreIOState.h"
15 
16 typedef void STCB(void *, StoreIOBuffer); /* store callback */
17 
18 class StoreEntry;
19 class ACLFilledChecklist;
20 class LogTags;
21 
24 {
25 
26 public:
27  virtual ~StoreClient () {}
28 
29  // TODO: Remove? Probably added to make lookups asynchronous, but they are
30  // still blocking. A lot more is needed to support async callbacks.
33  virtual void created(StoreEntry *) = 0;
34 
36  virtual LogTags *loggingTags() = 0;
37 
38 protected:
40  virtual void fillChecklist(ACLFilledChecklist &) const = 0;
41 
45  bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation);
46 
47  // These methods only interpret Squid configuration. Their allowances are
48  // provisional -- other factors may prevent collapsed forwarding. The first
49  // two exist primarily to distinguish two major CF cases in callers code.
51  bool mayInitiateCollapsing() const { return onCollapsingPath(); }
53  bool onCollapsingPath() const;
54 };
55 
56 #if USE_DELAY_POOLS
57 #include "DelayId.h"
58 #endif
59 
60 /* keep track each client receiving data from that particular StoreEntry */
61 
63 {
65 
66 public:
68  ~store_client();
69  bool memReaderHasLowerOffset(int64_t) const;
70  int getType() const;
71  void fail();
72  void callback(ssize_t len, bool error = false);
73  void doCopy (StoreEntry *e);
74  void readHeader(const char *buf, ssize_t len);
75  void readBody(const char *buf, ssize_t len);
76  void copy(StoreEntry *, StoreIOBuffer, STCB *, void *);
77  void dumpStats(MemBuf * output, int clientNumber) const;
78 
79  int64_t cmp_offset;
80 #if STORE_CLIENT_LIST_DEBUG
81 
82  void *owner;
83 #endif
84 
85  StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
87 
88  struct {
92  } flags;
93 
94 #if USE_DELAY_POOLS
96  void setDelayId(DelayId delay_id);
97 #endif
98 
100  /* Below here is private - do no alter outside storeClient calls */
102 
103 private:
104  bool moreToSend() const;
105 
106  void fileRead();
107  void scheduleDiskRead();
108  void scheduleMemRead();
109  void scheduleRead();
110  bool startSwapin();
111  bool unpackHeader(char const *buf, ssize_t len);
112 
113  int type;
114  bool object_ok;
115 
116  /* Until we finish stuffing code into store_client */
117 
118 public:
119 
120  struct Callback {
122 
123  Callback (STCB *, void *);
124  bool pending() const;
127  } _callback;
128 };
129 
133 int storeUnregister(store_client * sc, StoreEntry * e, void *data);
134 int storePendingNClients(const StoreEntry * e);
135 int storeClientIsThisAClient(store_client * sc, void *someClient);
136 
137 #endif /* SQUID_STORECLIENT_H */
138 
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation)
Definition: store_client.cc:65
bool moreToSend() const
Whether there is (or will be) more entry data for us.
void storeClientCopy(store_client *sc, StoreEntry *e, StoreIOBuffer copyInto, STCB *callback, void *data)
static int sc[16]
Definition: smbdes.c:121
int storeClientCopyPending(store_client *sc, StoreEntry *e, void *data)
int storePendingNClients(const StoreEntry *e)
void error(char *format,...)
int getType() const
bool startSwapin()
opens the swapin "file" if possible; otherwise, fail()s and returns false
store_client * storeClientListAdd(StoreEntry *e, void *data)
bool memReaderHasLowerOffset(int64_t) const
Definition: store_client.cc:96
store_client(StoreEntry *)
struct store_client::@145 flags
void setDelayId(DelayId delay_id)
dlink_node node
Definition: StoreClient.h:99
void readBody(const char *buf, ssize_t len)
void const char HLPCB void * data
Definition: stub_helper.cc:16
int storeClientIsThisAClient(store_client *sc, void *someClient)
bool unpackHeader(char const *buf, ssize_t len)
void scheduleDiskRead()
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
StoreIOBuffer copyInto
Definition: StoreClient.h:101
virtual ~StoreClient()
Definition: StoreClient.h:27
StoreIOState::Pointer swapin_sio
Definition: StoreClient.h:86
bool copy_event_pending
Definition: StoreClient.h:91
void scheduleMemRead()
StoreEntry * entry
Definition: StoreClient.h:85
int64_t cmp_offset
Definition: StoreClient.h:79
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
void dumpStats(MemBuf *output, int clientNumber) const
void const char * buf
Definition: stub_helper.cc:16
virtual void created(StoreEntry *)=0
void doCopy(StoreEntry *e)
virtual LogTags * loggingTags()=0
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
bool store_copying
Definition: StoreClient.h:90
virtual void fillChecklist(ACLFilledChecklist &) const =0
configure the ACL checklist with the current transaction state
Definition: store_client.cc:87
void copy(StoreEntry *, StoreIOBuffer, STCB *, void *)
void STCB(void *, StoreIOBuffer)
Definition: StoreClient.h:16
bool disk_io_pending
Definition: StoreClient.h:89
Definition: MemBuf.h:23
void scheduleRead()
void readHeader(const char *buf, ssize_t len)
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition: StoreClient.h:51
DelayId delayId
Definition: StoreClient.h:95
bool onCollapsingPath() const
whether Squid configuration allows collapsing for this transaction
Definition: store_client.cc:51
#define NULL
Definition: types.h:166
struct store_client::Callback _callback
void callback(ssize_t len, bool error=false)
A StoreEntry::getPublic*() caller.
Definition: StoreClient.h:23

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors