pconn.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2020 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_PCONN_H
10 #define SQUID_PCONN_H
11 
12 #include "base/CbcPointer.h"
13 #include "base/RunnersRegistry.h"
14 #include "mgr/forward.h"
15 
16 #include <set>
17 
23 class PconnPool;
24 class PeerPoolMgr;
25 
26 #include "cbdata.h"
27 #include "hash.h"
28 /* for IOCB */
29 #include "comm.h"
30 
32 #define PCONN_HIST_SZ (1<<16)
33 
38 {
40 
41 public:
42  IdleConnList(const char *key, PconnPool *parent);
43  ~IdleConnList();
44 
46  void push(const Comm::ConnectionPointer &conn);
47 
50 
58 
60 
61  int count() const { return size_; }
62  void closeN(size_t count);
63 
64  // IndependentRunner API
65  virtual void endingShutdown();
66 private:
67  bool isAvailable(int i) const;
68  bool removeAt(int index);
69  int findIndexOf(const Comm::ConnectionPointer &conn) const;
71  static IOCB Read;
72  static CTCB Timeout;
73 
74 private:
81 
83  int capacity_;
85  int size_;
86 
93 
94  char fakeReadBuf_[4096]; // TODO: kill magic number.
95 };
96 
97 #include "ip/forward.h"
98 
99 class StoreEntry;
100 class IdleConnLimit;
101 
102 /* for hash_table */
103 #include "hash.h"
104 
113 {
114 
115 public:
116  PconnPool(const char *aDescription, const CbcPointer<PeerPoolMgr> &aMgr);
117  ~PconnPool();
118 
119  void moduleInit();
120  void push(const Comm::ConnectionPointer &serverConn, const char *domain);
121 
134  Comm::ConnectionPointer pop(const Comm::ConnectionPointer &dest, const char *domain, bool keepOpen);
135  void count(int uses);
136  void dumpHist(StoreEntry *e) const;
137  void dumpHash(StoreEntry *e) const;
138  void unlinkList(IdleConnList *list);
139  void noteUses(int uses);
141  void closeN(int n);
142  int count() const { return theCount; }
145 
146  // sends an async message to the pool manager, if any
147  void notifyManager(const char *reason);
148 
149 private:
150 
151  static const char *key(const Comm::ConnectionPointer &destLink, const char *domain);
152 
153  Comm::ConnectionPointer popStored(const Comm::ConnectionPointer &dest, const char *domain, const bool keepOpen);
154 
157  const char *descr;
159  int theCount;
160 };
161 
162 class StoreEntry;
163 class PconnPool;
164 
169 {
170 
171 public:
175  static PconnModule * GetInstance();
177  static void DumpWrapper(StoreEntry *e);
178 
179  PconnModule();
180  void registerWithCacheManager(void);
181 
182  void add(PconnPool *);
183  void remove(PconnPool *);
184 
186 
187 private:
188  typedef std::set<PconnPool*> Pools;
190 
192 };
193 
194 #endif /* SQUID_PCONN_H */
195 
Maintains an fixed-size "standby" PconnPool for a single CachePeer.
Definition: PeerPoolMgr.h:21
void closeN(int n)
closes any n connections, regardless of their destination
Definition: pconn.cc:507
A RegisteredRunner with lifetime determined by forces outside the Registry.
std::set< PconnPool * > Pools
unordered PconnPool collection
Definition: pconn.h:188
~PconnPool()
Definition: pconn.cc:403
int findIndexOf(const Comm::ConnectionPointer &conn) const
Definition: pconn.cc:72
void closeN(size_t count)
Definition: pconn.cc:113
static IOCB Read
Definition: pconn.h:71
Comm::ConnectionPointer pop(const Comm::ConnectionPointer &dest, const char *domain, bool keepOpen)
Definition: pconn.cc:449
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
void noteConnectionAdded()
Definition: pconn.h:143
static PconnModule * GetInstance()
Definition: pconn.cc:556
void noteUses(int uses)
Definition: pconn.cc:536
Comm::ConnectionPointer popStored(const Comm::ConnectionPointer &dest, const char *domain, const bool keepOpen)
Definition: pconn.cc:468
void dumpHash(StoreEntry *e) const
Definition: pconn.cc:369
virtual void endingShutdown()
Definition: pconn.cc:323
void findAndClose(const Comm::ConnectionPointer &conn)
Definition: pconn.cc:284
static void DumpWrapper(StoreEntry *e)
Definition: pconn.cc:599
Comm::ConnectionPointer findUseable(const Comm::ConnectionPointer &key)
Definition: pconn.cc:245
void push(const Comm::ConnectionPointer &conn)
Pass control of the connection to the idle list.
Definition: pconn.cc:168
void moduleInit()
Pools pools
all live pools
Definition: pconn.h:189
Comm::ConnectionPointer pop()
get first conn which is not pending read fd.
Definition: pconn.cc:213
OBJH dump
Definition: pconn.h:185
const char * descr
Definition: pconn.h:157
void OBJH(StoreEntry *)
Definition: forward.h:44
void notifyManager(const char *reason)
Definition: pconn.cc:500
void add(PconnPool *)
Definition: pconn.cc:573
void CTCB(const CommTimeoutCbParams &params)
Definition: CommCalls.h:39
CbcPointer< PeerPoolMgr > mgr
optional pool manager (for notifications)
Definition: pconn.h:158
IdleConnList(const char *key, PconnPool *parent)
Definition: pconn.cc:34
void noteConnectionRemoved()
Definition: pconn.h:144
void push(const Comm::ConnectionPointer &serverConn, const char *domain)
Definition: pconn.cc:412
void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int xerrno, void *data)
Definition: CommCalls.h:36
int count() const
Definition: pconn.h:61
int conn
the current server connection FD
Definition: Transport.cc:26
#define assert(EX)
Definition: assert.h:19
~IdleConnList()
Definition: pconn.cc:50
void registerWithCacheManager(void)
Definition: pconn.cc:565
int count() const
Definition: pconn.h:142
PconnPool * parent_
Definition: pconn.h:92
void unlinkList(IdleConnList *list)
Definition: pconn.cc:528
void clearHandlers(const Comm::ConnectionPointer &conn)
Definition: pconn.cc:160
bool isAvailable(int i) const
Definition: pconn.cc:197
void remove(PconnPool *)
unregister and forget about this pool object
Definition: pconn.cc:579
PconnPool(const char *aDescription, const CbcPointer< PeerPoolMgr > &aMgr)
Definition: pconn.cc:383
int theCount
the number of pooled connections
Definition: pconn.h:159
int size_
Definition: pconn.h:85
int hist[PCONN_HIST_SZ]
Definition: pconn.h:155
Comm::ConnectionPointer * theList_
Definition: pconn.h:80
static CTCB Timeout
Definition: pconn.h:72
#define PCONN_HIST_SZ
Definition: pconn.h:32
void dumpHist(StoreEntry *e) const
Definition: pconn.cc:351
PconnModule()
Definition: pconn.cc:550
hash_table * table
Definition: pconn.h:156
static PconnModule * instance
Definition: pconn.h:191
int capacity_
Number of entries theList can currently hold without re-allocating (capacity).
Definition: pconn.h:83
static const char * key(const Comm::ConnectionPointer &destLink, const char *domain)
Definition: pconn.cc:331
bool removeAt(int index)
Definition: pconn.cc:90
char fakeReadBuf_[4096]
Definition: pconn.h:94

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors