]> git.ipfire.org Git - thirdparty/squid.git/blame - src/pconn.h
At the sprint the issue about our current 10ms main loop timeout came
[thirdparty/squid.git] / src / pconn.h
CommitLineData
781ce8ff 1
2#ifndef SQUID_PCONN_H
3#define SQUID_PCONN_H
4
62ee09ca 5/* forward decls */
6
7class CacheManager;
781ce8ff 8
9class PconnPool;
10
62ee09ca 11#define MAX_NUM_PCONN_POOLS 10
12#define PCONN_HIST_SZ (1<<16)
13
781ce8ff 14class IdleConnList
15{
16
17public:
18 IdleConnList(const char *key, PconnPool *parent);
19 ~IdleConnList();
20 int numIdle() { return nfds; }
21
0c8a9718 22 int findFDIndex(int fd); ///< search from the end of array
781ce8ff 23 void removeFD(int fd);
24 void push(int fd);
0c8a9718 25 int findUseableFD(); ///< find first from the end not pending read fd.
781ce8ff 26 void clearHandlers(int fd);
27
28private:
29 static IOCB read;
30 static PF timeout;
31
32public:
33 hash_link hash; /* must be first */
34
35private:
36 int *fds;
37 int nfds_alloc;
38 int nfds;
39 PconnPool *parent;
40 char fakeReadBuf[4096];
41 CBDATA_CLASS2(IdleConnList);
42};
43
44class PconnPool
45{
46
47public:
48 PconnPool(const char *);
49
50 void moduleInit();
cc192b50 51 void push(int fd, const char *host, u_short port, const char *domain, IPAddress &client_address);
52 int pop(const char *host, u_short port, const char *domain, IPAddress &client_address, bool retriable);
781ce8ff 53 void count(int uses);
54 void dumpHist(StoreEntry *e);
55 void unlinkList(IdleConnList *list) const;
56
57private:
58
cc192b50 59 static const char *key(const char *host, u_short port, const char *domain, IPAddress &client_address);
781ce8ff 60
61 int hist[PCONN_HIST_SZ];
62 hash_table *table;
63 const char *descr;
64
65};
66
67class PconnModule
68{
69
70public:
62ee09ca 71 /* the module is a singleton until we have instance based cachemanager
72 * management
73 */
74 static PconnModule * GetInstance();
75 /* A thunk to the still C like CacheManager callback api. */
76 static void DumpWrapper(StoreEntry *e);
77
781ce8ff 78 PconnModule();
62ee09ca 79 void registerWithCacheManager(CacheManager & manager);
781ce8ff 80
81 void add
82 (PconnPool *);
83
84 OBJH dump;
85
86private:
87 PconnPool **pools;
88
62ee09ca 89 static PconnModule * instance;
90
781ce8ff 91 int poolCount;
92};
93
94#endif /* SQUID_PCONN_H */