]>
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"
17 class CommConnectCbParams
;
22 class PeerConnectorAnswer
;
26 /// Maintains an fixed-size "standby" PconnPool for a single CachePeer.
27 class PeerPoolMgr
: public AsyncJob
29 CBDATA_CLASS(PeerPoolMgr
);
32 typedef CbcPointer
<PeerPoolMgr
> Pointer
;
34 // syncs mgr state whenever connection-related peer or pool state changes
35 static void Checkpoint(const Pointer
&mgr
, const char *reason
);
37 explicit PeerPoolMgr(CachePeer
*aPeer
);
38 virtual ~PeerPoolMgr();
43 virtual void swanSong();
44 virtual bool doneAll() const;
46 /// whether the peer is still out there and in a valid state we can safely use
47 bool validPeer() const;
49 /// Starts new connection, or closes the excess connections
50 /// according pool configuration
51 void checkpoint(const char *reason
);
52 /// starts the process of opening a new standby connection (if possible)
53 void openNewConnection();
54 /// closes 'howMany' standby connections
55 void closeOldConnections(const int howMany
);
57 /// Comm::ConnOpener calls this when done opening a connection for us
58 void handleOpenedConnection(const CommConnectCbParams
¶ms
);
60 /// Ssl::PeerConnector callback
61 void handleSecuredPeer(Ssl::PeerConnectorAnswer
&answer
);
62 /// called when the connection we are trying to secure is closed by a 3rd party
63 void handleSecureClosure(const CommCloseCbParams
¶ms
);
65 /// the final step in connection opening (and, optionally, securing) sequence
66 void pushNewConnection(const Comm::ConnectionPointer
&conn
);
69 CachePeer
*peer
; ///< the owner of the pool we manage
70 RefCount
<HttpRequest
> request
; ///< fake HTTP request for conn opening code
71 AsyncCall::Pointer opener
; ///< whether we are opening a connection
72 AsyncCall::Pointer securer
; ///< whether we are securing a connection
73 AsyncCall::Pointer closer
; ///< monitors conn while we are securing it
74 unsigned int addrUsed
; ///< counter for cycling through peer addresses
77 #endif /* SQUID_PEERPOOLMGR_H */