]> git.ipfire.org Git - thirdparty/squid.git/blame - src/PeerPoolMgr.h
Simplify appending SBuf to String (#2108)
[thirdparty/squid.git] / src / PeerPoolMgr.h
CommitLineData
bbc27441 1/*
1f7b830e 2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
bbc27441
AJ
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
ff9d9458
FC
9#ifndef SQUID_SRC_PEERPOOLMGR_H
10#define SQUID_SRC_PEERPOOLMGR_H
e8dca475
CT
11
12#include "base/AsyncJob.h"
16cafa1f 13#include "base/forward.h"
2b6b1bcb 14#include "base/JobWait.h"
e8dca475 15#include "comm/forward.h"
fcfdf7f9 16#include "security/forward.h"
e8dca475
CT
17
18class HttpRequest;
19class CachePeer;
20class CommConnectCbParams;
21
e8dca475
CT
22/// Maintains an fixed-size "standby" PconnPool for a single CachePeer.
23class PeerPoolMgr: public AsyncJob
24{
337b9aa4 25 CBDATA_CHILD(PeerPoolMgr);
5c2f68b7 26
e8dca475
CT
27public:
28 typedef CbcPointer<PeerPoolMgr> Pointer;
29
30 // syncs mgr state whenever connection-related peer or pool state changes
31 static void Checkpoint(const Pointer &mgr, const char *reason);
32
33 explicit PeerPoolMgr(CachePeer *aPeer);
337b9aa4 34 ~PeerPoolMgr() override;
e8dca475 35
16cafa1f
EB
36 PrecomputedCodeContextPointer codeContext;
37
e8dca475
CT
38protected:
39 /* AsyncJob API */
337b9aa4
AR
40 void start() override;
41 void swanSong() override;
42 bool doneAll() const override;
e8dca475
CT
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);
fcfdf7f9 57
a72b6e88 58 /// Security::PeerConnector callback
fcfdf7f9
AJ
59 void handleSecuredPeer(Security::EncryptorAnswer &answer);
60
e8dca475
CT
61 /// the final step in connection opening (and, optionally, securing) sequence
62 void pushNewConnection(const Comm::ConnectionPointer &conn);
63
64private:
65 CachePeer *peer; ///< the owner of the pool we manage
66 RefCount<HttpRequest> request; ///< fake HTTP request for conn opening code
2b6b1bcb
AR
67
68 /// waits for a transport connection to the peer to be established/opened
69 JobWait<Comm::ConnOpener> transportWait;
70
71 /// waits for the established transport connection to be secured/encrypted
72 JobWait<Security::BlindPeerConnector> encryptionWait;
73
e8dca475 74 unsigned int addrUsed; ///< counter for cycling through peer addresses
e8dca475
CT
75};
76
ff9d9458 77#endif /* SQUID_SRC_PEERPOOLMGR_H */
f53969cc 78