]> git.ipfire.org Git - thirdparty/squid.git/blame - src/pconn.h
Build fixes
[thirdparty/squid.git] / src / pconn.h
CommitLineData
e1f7507e
AJ
1/*
2 * $Id$
3 */
781ce8ff 4#ifndef SQUID_PCONN_H
5#define SQUID_PCONN_H
6
e1f7507e
AJ
7/**
8 \defgroup PConnAPI Persistent Connection API
9 \ingroup Component
10 *
11 \todo CLEANUP: Break multiple classes out of the generic pconn.h header
12 */
62ee09ca 13
781ce8ff 14class PconnPool;
15
e1f7507e
AJ
16/* for CBDATA_CLASS2() macros */
17#include "cbdata.h"
18/* for hash_link */
19#include "hash.h"
20/* for IOCB */
21#include "comm.h"
22
23/// \ingroup PConnAPI
62ee09ca 24#define MAX_NUM_PCONN_POOLS 10
e1f7507e
AJ
25
26/// \ingroup PConnAPI
62ee09ca 27#define PCONN_HIST_SZ (1<<16)
28
855150a4
AJ
29/** \ingroup PConnAPI
30 * A list of connections currently open to a particular destination end-point.
31 * We currently define the end-point by the FQDN it is serving.
32 */
781ce8ff 33class IdleConnList
34{
781ce8ff 35public:
36 IdleConnList(const char *key, PconnPool *parent);
37 ~IdleConnList();
38 int numIdle() { return nfds; }
39
0c8a9718 40 int findFDIndex(int fd); ///< search from the end of array
781ce8ff 41 void removeFD(int fd);
42 void push(int fd);
0c8a9718 43 int findUseableFD(); ///< find first from the end not pending read fd.
781ce8ff 44 void clearHandlers(int fd);
45
46private:
47 static IOCB read;
48 static PF timeout;
49
50public:
e1f7507e 51 hash_link hash; /** must be first */
781ce8ff 52
53private:
54 int *fds;
55 int nfds_alloc;
56 int nfds;
57 PconnPool *parent;
58 char fakeReadBuf[4096];
59 CBDATA_CLASS2(IdleConnList);
60};
61
e1f7507e 62
e06b8df8
HN
63#include "ip/forward.h"
64
e1f7507e
AJ
65class StoreEntry;
66class IdleConnLimit;
67
68/* for hash_table */
69#include "hash.h"
70
855150a4
AJ
71/** \ingroup PConnAPI
72 * A pool of persistent connections for a particular service type.
73 * HTTP servers being one such pool type, ICAP services another etc.
74 */
781ce8ff 75class PconnPool
76{
77
78public:
79 PconnPool(const char *);
7a56c509 80 ~PconnPool();
781ce8ff 81
82 void moduleInit();
b7ac5457
AJ
83 void push(int fd, const char *host, u_short port, const char *domain, Ip::Address &client_address);
84 int pop(const char *host, u_short port, const char *domain, Ip::Address &client_address, bool retriable);
781ce8ff 85 void count(int uses);
86 void dumpHist(StoreEntry *e);
06093389 87 void dumpHash(StoreEntry *e);
781ce8ff 88 void unlinkList(IdleConnList *list) const;
89
90private:
91
b7ac5457 92 static const char *key(const char *host, u_short port, const char *domain, Ip::Address &client_address);
781ce8ff 93
94 int hist[PCONN_HIST_SZ];
95 hash_table *table;
96 const char *descr;
97
98};
99
e1f7507e 100
e1f7507e
AJ
101class StoreEntry;
102class PconnPool;
103
855150a4
AJ
104/** \ingroup PConnAPI
105 * The global registry of persistent connection pools.
106 */
781ce8ff 107class PconnModule
108{
109
110public:
e1f7507e 111 /** the module is a singleton until we have instance based cachemanager
62ee09ca 112 * management
113 */
114 static PconnModule * GetInstance();
e1f7507e 115 /** A thunk to the still C like CacheManager callback api. */
62ee09ca 116 static void DumpWrapper(StoreEntry *e);
117
781ce8ff 118 PconnModule();
15fab853 119 void registerWithCacheManager(void);
781ce8ff 120
e1f7507e 121 void add(PconnPool *);
781ce8ff 122
123 OBJH dump;
124
125private:
126 PconnPool **pools;
127
62ee09ca 128 static PconnModule * instance;
129
781ce8ff 130 int poolCount;
131};
132
133#endif /* SQUID_PCONN_H */