]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 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 | ||
94bfd31f AJ |
9 | #ifndef SQUID_SRC_MASTERXACTION_H |
10 | #define SQUID_SRC_MASTERXACTION_H | |
11 | ||
12 | #include "anyp/forward.h" | |
5ceaee75 | 13 | #include "anyp/PortCfg.h" |
94bfd31f AJ |
14 | #include "base/InstanceId.h" |
15 | #include "base/Lock.h" | |
5ceaee75 | 16 | #include "base/RefCount.h" |
94bfd31f | 17 | #include "comm/forward.h" |
5ceaee75 | 18 | #include "XactionInitiator.h" |
94bfd31f AJ |
19 | |
20 | /** Master transaction details. | |
21 | * | |
22 | * Aggregates historical data from individual related protocol-specific | |
23 | * transactions such as an HTTP client transaction and the corresponding | |
24 | * HTTP or FTP server transaction. | |
25 | * | |
26 | * Individual transaction information worth sending or logging should be | |
27 | * recorded here, ideally without exposing other master transaction users | |
28 | * to internal details of individual transactions. For example, storing an | |
29 | * HTTP client IP address is a good idea but storing a pointer to some | |
30 | * client-side job which maintains that address is not. | |
31 | * | |
32 | * A master transaction is created by a newly accepted client connection, | |
33 | * a new request on the existing client connection, or an internal request | |
34 | * generated by Squid. All client-side protocols, including HTTP, HTCP, ICP, | |
35 | * and SNMP will eventually create master transactions. | |
36 | * | |
37 | * A master transaction is auto-destroyed when its last user is gone. | |
38 | */ | |
39 | class MasterXaction : public RefCountable | |
40 | { | |
41 | public: | |
42 | typedef RefCount<MasterXaction> Pointer; | |
43 | ||
ad05b958 EB |
44 | /// Create a master transaction not associated with a AnyP::PortCfg port. |
45 | template <XactionInitiator::Initiator anInitiator> | |
46 | static Pointer MakePortless() | |
47 | { | |
48 | static_assert(anInitiator != XactionInitiator::initClient, "not an HTTP or FTP client"); | |
49 | return new MasterXaction(anInitiator, nullptr); | |
50 | } | |
51 | ||
52 | /// Create a master transaction associated with a AnyP::PortCfg port. | |
53 | /// \param aPort may be nil if port information was lost | |
54 | static Pointer MakePortful(const AnyP::PortCfgPointer &aPort) | |
55 | { | |
56 | return new MasterXaction(XactionInitiator::initClient, aPort); | |
57 | } | |
5ceaee75 | 58 | |
94bfd31f | 59 | /// transaction ID. |
7cfd3a41 | 60 | InstanceId<MasterXaction, uint64_t> id; |
94bfd31f AJ |
61 | |
62 | /// the listening port which originated this transaction | |
63 | AnyP::PortCfgPointer squidPort; | |
64 | ||
65 | /// the client TCP connection which originated this transaction | |
66 | Comm::ConnectionPointer tcpClient; | |
67 | ||
5ceaee75 CT |
68 | /// the initiator of this transaction |
69 | XactionInitiator initiator; | |
70 | ||
090f1d3c CT |
71 | /// whether we are currently creating a CONNECT header (to be sent to peer) |
72 | bool generatingConnect = false; | |
73 | ||
94bfd31f | 74 | // TODO: add state from other Jobs in the transaction |
ad05b958 EB |
75 | |
76 | private: | |
77 | // use public Make() functions instead | |
78 | MasterXaction(const XactionInitiator anInitiator, const AnyP::PortCfgPointer &aPort): | |
79 | squidPort(aPort), | |
80 | initiator(anInitiator) | |
81 | {} | |
94bfd31f AJ |
82 | }; |
83 | ||
84 | #endif /* SQUID_SRC_MASTERXACTION_H */ | |
f53969cc | 85 |