1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
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 
9 #ifndef SQUID_SRC_MASTERXACTION_H
10 #define SQUID_SRC_MASTERXACTION_H
11 
12 #include "anyp/forward.h"
13 #include "anyp/PortCfg.h"
14 #include "base/InstanceId.h"
15 #include "base/Lock.h"
16 #include "base/RefCount.h"
17 #include "comm/forward.h"
18 #include "XactionInitiator.h"
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 
MasterXaction(const XactionInitiator anInitiator)44     explicit MasterXaction(const XactionInitiator anInitiator) : initiator(anInitiator) {};
45 
46     /// transaction ID.
47     InstanceId<MasterXaction> id;
48 
49     /// the listening port which originated this transaction
50     AnyP::PortCfgPointer squidPort;
51 
52     /// the client TCP connection which originated this transaction
53     Comm::ConnectionPointer tcpClient;
54 
55     /// the initiator of this transaction
56     XactionInitiator initiator;
57 
58     // TODO: add state from other Jobs in the transaction
59 };
60 
61 #endif /* SQUID_SRC_MASTERXACTION_H */
62 
63