pconn.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
25 class PconnPool;
26 class PeerPoolMgr;
27 
28 #include "cbdata.h"
29 #include "hash.h"
30 /* for IOCB */
31 #include "comm.h"
32 
34 #define PCONN_HIST_SZ (1<<16)
35 
40 {
42 
43 public:
44  IdleConnList(const char *key, PconnPool *parent);
45  ~IdleConnList();
46 
48  void push(const Comm::ConnectionPointer &conn);
49 
52 
60 
62 
63  int count() const { return size_; }
64  void closeN(size_t count);
65 
66  // IndependentRunner API
67  virtual void endingShutdown();
68 private:
69  bool isAvailable(int i) const;
70  bool removeAt(int index);
71  int findIndexOf(const Comm::ConnectionPointer &conn) const;
73  static IOCB Read;
74  static CTCB Timeout;
75 
76 private:
83 
85  int capacity_;
87  int size_;
88 
95 
96  char fakeReadBuf_[4096]; // TODO: kill magic number.
97 };
98 
99 #include "ip/forward.h"
100 
101 class StoreEntry;
102 class IdleConnLimit;
103 
104 /* for hash_table */
105 #include "hash.h"
106 
115 {
116 
117 public:
118  PconnPool(const char *aDescription, const CbcPointer<PeerPoolMgr> &aMgr);
119  ~PconnPool();
120 
121  void moduleInit();
122  void push(const Comm::ConnectionPointer &serverConn, const char *domain);
123 
135  Comm::ConnectionPointer pop(const Comm::ConnectionPointer &dest, const char *domain, bool keepOpen);
136  void count(int uses);
137  void dumpHist(StoreEntry *e) const;
138  void dumpHash(StoreEntry *e) const;
139  void unlinkList(IdleConnList *list);
140  void noteUses(int uses);
142  void closeN(int n);
143  int count() const { return theCount; }
146 
147  // sends an async message to the pool manager, if any
148  void notifyManager(const char *reason);
149 
150 private:
151 
152  static const char *key(const Comm::ConnectionPointer &destLink, const char *domain);
153 
156  const char *descr;
158  int theCount;
159 };
160 
161 class StoreEntry;
162 class PconnPool;
163 
168 {
169 
170 public:
174  static PconnModule * GetInstance();
176  static void DumpWrapper(StoreEntry *e);
177 
178  PconnModule();
179  void registerWithCacheManager(void);
180 
181  void add(PconnPool *);
182  void remove(PconnPool *);
183 
185 
186 private:
187  typedef std::set<PconnPool*> Pools;
189 
191 };
192 
193 #endif /* SQUID_PCONN_H */
194 
int findIndexOf(const Comm::ConnectionPointer &conn) const
Definition: pconn.cc:72
char fakeReadBuf_[4096]
Definition: pconn.h:96
void closeN(int n)
closes any n connections, regardless of their destination
Definition: pconn.cc:478
static const char * key(const Comm::ConnectionPointer &destLink, const char *domain)
Definition: pconn.cc:331
#define assert(EX)
Definition: assert.h:17
void noteUses(int uses)
Definition: pconn.cc:507
void CTCB(const CommTimeoutCbParams &params)
Definition: CommCalls.h:39
~PconnPool()
Definition: pconn.cc:398
void registerWithCacheManager(void)
Definition: pconn.cc:536
int count() const
Definition: pconn.h:143
int i
Definition: membanger.c:49
CbcPointer< PeerPoolMgr > mgr
optional pool manager (for notifications)
Definition: pconn.h:157
static IOCB Read
Definition: pconn.h:73
void moduleInit()
void OBJH(StoreEntry *)
Definition: forward.h:44
int conn
the current server connection FD
Definition: Transport.cc:26
void closeN(size_t count)
Definition: pconn.cc:113
PconnModule()
Definition: pconn.cc:521
const char * descr
Definition: pconn.h:156
static PconnModule * instance
Definition: pconn.h:190
void noteConnectionAdded()
Definition: pconn.h:144
int count() const
Definition: pconn.h:63
void push(const Comm::ConnectionPointer &serverConn, const char *domain)
Definition: pconn.cc:407
Comm::ConnectionPointer findUseable(const Comm::ConnectionPointer &key)
Definition: pconn.cc:245
~IdleConnList()
Definition: pconn.cc:50
void dumpHash(StoreEntry *e) const
Definition: pconn.cc:364
virtual void endingShutdown()
Definition: pconn.cc:323
void push(const Comm::ConnectionPointer &conn)
Pass control of the connection to the idle list.
Definition: pconn.cc:168
void findAndClose(const Comm::ConnectionPointer &conn)
Definition: pconn.cc:284
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
Comm::ConnectionPointer pop()
get first conn which is not pending read fd.
Definition: pconn.cc:213
void noteConnectionRemoved()
Definition: pconn.h:145
std::set< PconnPool * > Pools
unordered PconnPool collection
Definition: pconn.h:187
void unlinkList(IdleConnList *list)
Definition: pconn.cc:499
int size_
Definition: pconn.h:87
void notifyManager(const char *reason)
Definition: pconn.cc:471
static CTCB Timeout
Definition: pconn.h:74
void clearHandlers(const Comm::ConnectionPointer &conn)
Definition: pconn.cc:160
IdleConnList(const char *key, PconnPool *parent)
Definition: pconn.cc:34
A RegisteredRunner with lifetime determined by forces outside the Registry.
void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int xerrno, void *data)
Definition: CommCalls.h:36
bool isAvailable(int i) const
Definition: pconn.cc:197
PconnPool(const char *aDescription, const CbcPointer< PeerPoolMgr > &aMgr)
Definition: pconn.cc:378
void dumpHist(StoreEntry *e) const
Definition: pconn.cc:346
hash_table * table
Definition: pconn.h:155
int hist[PCONN_HIST_SZ]
Definition: pconn.h:154
static PconnModule * GetInstance()
Definition: pconn.cc:527
PconnPool * parent_
Definition: pconn.h:94
Maintains an fixed-size "standby" PconnPool for a single CachePeer.
Definition: PeerPoolMgr.h:21
Pools pools
all live pools
Definition: pconn.h:188
Comm::ConnectionPointer * theList_
Definition: pconn.h:82
void add(PconnPool *)
Definition: pconn.cc:544
bool removeAt(int index)
Definition: pconn.cc:90
static void DumpWrapper(StoreEntry *e)
Definition: pconn.cc:570
int capacity_
Number of entries theList can currently hold without re-allocating (capacity).
Definition: pconn.h:85
#define PCONN_HIST_SZ
Definition: pconn.h:34
int theCount
the number of pooled connections
Definition: pconn.h:158
OBJH dump
Definition: pconn.h:184
Comm::ConnectionPointer pop(const Comm::ConnectionPointer &dest, const char *domain, bool keepOpen)
Definition: pconn.cc:444

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors