]>
Commit | Line | Data |
---|---|---|
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 | 14 | class 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 | 33 | class IdleConnList |
34 | { | |
781ce8ff | 35 | public: |
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 | ||
46 | private: | |
47 | static IOCB read; | |
48 | static PF timeout; | |
49 | ||
50 | public: | |
e1f7507e | 51 | hash_link hash; /** must be first */ |
781ce8ff | 52 | |
53 | private: | |
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 |
65 | class StoreEntry; |
66 | class 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 | 75 | class PconnPool |
76 | { | |
77 | ||
78 | public: | |
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 | ||
90 | private: | |
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 |
101 | class StoreEntry; |
102 | class PconnPool; | |
103 | ||
855150a4 AJ |
104 | /** \ingroup PConnAPI |
105 | * The global registry of persistent connection pools. | |
106 | */ | |
781ce8ff | 107 | class PconnModule |
108 | { | |
109 | ||
110 | public: | |
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 | ||
125 | private: | |
126 | PconnPool **pools; | |
127 | ||
62ee09ca | 128 | static PconnModule * instance; |
129 | ||
781ce8ff | 130 | int poolCount; |
131 | }; | |
132 | ||
133 | #endif /* SQUID_PCONN_H */ |