]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/PeerPoolMgr.h
1 #ifndef SQUID_PEERPOOLMGR_H
2 #define SQUID_PEERPOOLMGR_H
4 #include "base/AsyncJob.h"
5 #include "comm/forward.h"
9 class CommConnectCbParams
;
14 class PeerConnectorAnswer
;
18 /// Maintains an fixed-size "standby" PconnPool for a single CachePeer.
19 class PeerPoolMgr
: public AsyncJob
22 typedef CbcPointer
<PeerPoolMgr
> Pointer
;
24 // syncs mgr state whenever connection-related peer or pool state changes
25 static void Checkpoint(const Pointer
&mgr
, const char *reason
);
27 explicit PeerPoolMgr(CachePeer
*aPeer
);
28 virtual ~PeerPoolMgr();
33 virtual void swanSong();
34 virtual bool doneAll() const;
36 /// whether the peer is still out there and in a valid state we can safely use
37 bool validPeer() const;
39 /// Starts new connection, or closes the excess connections
40 /// according pool configuration
41 void checkpoint(const char *reason
);
42 /// starts the process of opening a new standby connection (if possible)
43 void openNewConnection();
44 /// closes 'howMany' standby connections
45 void closeOldConnections(const int howMany
);
47 /// Comm::ConnOpener calls this when done opening a connection for us
48 void handleOpenedConnection(const CommConnectCbParams
¶ms
);
50 /// Ssl::PeerConnector callback
51 void handleSecuredPeer(Ssl::PeerConnectorAnswer
&answer
);
52 /// called when the connection we are trying to secure is closed by a 3rd party
53 void handleSecureClosure(const CommCloseCbParams
¶ms
);
55 /// the final step in connection opening (and, optionally, securing) sequence
56 void pushNewConnection(const Comm::ConnectionPointer
&conn
);
59 CachePeer
*peer
; ///< the owner of the pool we manage
60 RefCount
<HttpRequest
> request
; ///< fake HTTP request for conn opening code
61 AsyncCall::Pointer opener
; ///< whether we are opening a connection
62 AsyncCall::Pointer securer
; ///< whether we are securing a connection
63 AsyncCall::Pointer closer
; ///< monitors conn while we are securing it
64 unsigned int addrUsed
; ///< counter for cycling through peer addresses
66 CBDATA_CLASS2(PeerPoolMgr
);
69 #endif /* SQUID_PEERPOOLMGR_H */