]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/PeerPoolMgr.h
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_PEERPOOLMGR_H
10 #define SQUID_PEERPOOLMGR_H
12 #include "base/AsyncJob.h"
13 #include "comm/forward.h"
14 #include "security/forward.h"
18 class CommConnectCbParams
;
20 /// Maintains an fixed-size "standby" PconnPool for a single CachePeer.
21 class PeerPoolMgr
: public AsyncJob
23 CBDATA_CLASS(PeerPoolMgr
);
26 typedef CbcPointer
<PeerPoolMgr
> Pointer
;
28 // syncs mgr state whenever connection-related peer or pool state changes
29 static void Checkpoint(const Pointer
&mgr
, const char *reason
);
31 explicit PeerPoolMgr(CachePeer
*aPeer
);
32 virtual ~PeerPoolMgr();
37 virtual void swanSong();
38 virtual bool doneAll() const;
40 /// whether the peer is still out there and in a valid state we can safely use
41 bool validPeer() const;
43 /// Starts new connection, or closes the excess connections
44 /// according pool configuration
45 void checkpoint(const char *reason
);
46 /// starts the process of opening a new standby connection (if possible)
47 void openNewConnection();
48 /// closes 'howMany' standby connections
49 void closeOldConnections(const int howMany
);
51 /// Comm::ConnOpener calls this when done opening a connection for us
52 void handleOpenedConnection(const CommConnectCbParams
¶ms
);
54 /// Ssl::PeerConnector callback
55 void handleSecuredPeer(Security::EncryptorAnswer
&answer
);
57 /// called when the connection we are trying to secure is closed by a 3rd party
58 void handleSecureClosure(const CommCloseCbParams
¶ms
);
60 /// the final step in connection opening (and, optionally, securing) sequence
61 void pushNewConnection(const Comm::ConnectionPointer
&conn
);
64 CachePeer
*peer
; ///< the owner of the pool we manage
65 RefCount
<HttpRequest
> request
; ///< fake HTTP request for conn opening code
66 AsyncCall::Pointer opener
; ///< whether we are opening a connection
67 AsyncCall::Pointer securer
; ///< whether we are securing a connection
68 AsyncCall::Pointer closer
; ///< monitors conn while we are securing it
69 unsigned int addrUsed
; ///< counter for cycling through peer addresses
72 #endif /* SQUID_PEERPOOLMGR_H */