]> git.ipfire.org Git - thirdparty/squid.git/blame - src/PeerPoolMgr.h
Docs: Add man(8) page for helper-mux tool
[thirdparty/squid.git] / src / PeerPoolMgr.h
CommitLineData
bbc27441
AJ
1/*
2 * Copyright (C) 1996-2014 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
e8dca475
CT
9#ifndef SQUID_PEERPOOLMGR_H
10#define SQUID_PEERPOOLMGR_H
11
12#include "base/AsyncJob.h"
13#include "comm/forward.h"
14
15class HttpRequest;
16class CachePeer;
17class CommConnectCbParams;
18
19#if USE_OPENSSL
e2849af8
A
20namespace Ssl
21{
22class PeerConnectorAnswer;
e8dca475
CT
23}
24#endif
25
26/// Maintains an fixed-size "standby" PconnPool for a single CachePeer.
27class PeerPoolMgr: public AsyncJob
28{
29public:
30 typedef CbcPointer<PeerPoolMgr> Pointer;
31
32 // syncs mgr state whenever connection-related peer or pool state changes
33 static void Checkpoint(const Pointer &mgr, const char *reason);
34
35 explicit PeerPoolMgr(CachePeer *aPeer);
36 virtual ~PeerPoolMgr();
37
38protected:
39 /* AsyncJob API */
40 virtual void start();
41 virtual void swanSong();
42 virtual bool doneAll() const;
43
44 /// whether the peer is still out there and in a valid state we can safely use
45 bool validPeer() const;
46
47 /// Starts new connection, or closes the excess connections
48 /// according pool configuration
49 void checkpoint(const char *reason);
50 /// starts the process of opening a new standby connection (if possible)
51 void openNewConnection();
52 /// closes 'howMany' standby connections
53 void closeOldConnections(const int howMany);
54
55 /// Comm::ConnOpener calls this when done opening a connection for us
56 void handleOpenedConnection(const CommConnectCbParams &params);
57#if USE_OPENSSL
58 /// Ssl::PeerConnector callback
59 void handleSecuredPeer(Ssl::PeerConnectorAnswer &answer);
60 /// called when the connection we are trying to secure is closed by a 3rd party
61 void handleSecureClosure(const CommCloseCbParams &params);
62#endif
63 /// the final step in connection opening (and, optionally, securing) sequence
64 void pushNewConnection(const Comm::ConnectionPointer &conn);
65
66private:
67 CachePeer *peer; ///< the owner of the pool we manage
68 RefCount<HttpRequest> request; ///< fake HTTP request for conn opening code
69 AsyncCall::Pointer opener; ///< whether we are opening a connection
70 AsyncCall::Pointer securer; ///< whether we are securing a connection
71 AsyncCall::Pointer closer; ///< monitors conn while we are securing it
72 unsigned int addrUsed; ///< counter for cycling through peer addresses
73
74 CBDATA_CLASS2(PeerPoolMgr);
75};
76
77#endif /* SQUID_PEERPOOLMGR_H */