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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors