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 
23 {
24 
25 public:
26  virtual ~StoreClient () {}
27 
28  // TODO: Remove? Probably added to make lookups asynchronous, but they are
29  // still blocking. A lot more is needed to support async callbacks.
32  virtual void created(StoreEntry *) = 0;
33 
34 protected:
36  virtual void fillChecklist(ACLFilledChecklist &) const = 0;
37 
38  // These methods only interpret Squid configuration. Their allowances are
39  // provisional -- other factors may prevent collapsed forwarding. The first
40  // two exist primarily to distinguish two major CF cases in callers code.
42  bool mayInitiateCollapsing() const { return onCollapsingPath(); }
44  bool mayCollapseOn(const StoreEntry &initiatorEntry) const;
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;
120  } _callback;
121 };
122 
126 int storeUnregister(store_client * sc, StoreEntry * e, void *data);
127 int storePendingNClients(const StoreEntry * e);
128 int storeClientIsThisAClient(store_client * sc, void *someClient);
129 
130 #endif /* SQUID_STORECLIENT_H */
131 
bool moreToSend() const
Whether there is (or will be) more entry data for us.
bool mayCollapseOn(const StoreEntry &initiatorEntry) const
whether Squid configuration allows collapsing on the initiatorEntry
Definition: store_client.cc:65
static int sc[16]
Definition: smbdes.c:121
void error(char *format,...)
int getType() const
Definition: store_client.cc:87
bool startSwapin()
opens the swapin "file" if possible; otherwise, fail()s and returns false
bool memReaderHasLowerOffset(int64_t) const
Definition: store_client.cc:81
store_client(StoreEntry *)
void setDelayId(DelayId delay_id)
dlink_node node
Definition: StoreClient.h:92
void readBody(const char *buf, ssize_t len)
void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *)
void const char HLPCB void * data
Definition: stub_helper.cc:16
int storePendingNClients(const StoreEntry *e)
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:94
virtual ~StoreClient()
Definition: StoreClient.h:26
StoreIOState::Pointer swapin_sio
Definition: StoreClient.h:79
bool copy_event_pending
Definition: StoreClient.h:84
void scheduleMemRead()
StoreEntry * entry
Definition: StoreClient.h:78
int64_t cmp_offset
Definition: StoreClient.h:72
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)
bool store_copying
Definition: StoreClient.h:83
virtual void fillChecklist(ACLFilledChecklist &) const =0
configure the ACL checklist with the current transaction state
Definition: store_client.cc:72
struct store_client::@146 flags
void copy(StoreEntry *, StoreIOBuffer, STCB *, void *)
store_client * storeClientListAdd(StoreEntry *e, void *data)
void STCB(void *, StoreIOBuffer)
Definition: StoreClient.h:16
bool disk_io_pending
Definition: StoreClient.h:82
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:42
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
DelayId delayId
Definition: StoreClient.h:88
int storeClientCopyPending(store_client *, StoreEntry *e, void *data)
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:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors