]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HierarchyLogEntry.h
Use ERR_ACCESS_DENIED for HTTP 403 (Forbidden) errors (#1899)
[thirdparty/squid.git] / src / HierarchyLogEntry.h
1 /*
2 * Copyright (C) 1996-2023 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_HIERARCHYLOGENTRY_H
10 #define SQUID_SRC_HIERARCHYLOGENTRY_H
11
12 #include "base/Stopwatch.h"
13 #include "comm/Connection.h"
14 #include "enums.h"
15 #include "hier_code.h"
16 #include "http/StatusCode.h"
17 #include "lookup_t.h"
18 #include "PingData.h"
19 #include "rfc2181.h"
20
21 /// Maintains peer selection details and peer I/O stats.
22 /// Here, "peer" is an origin server or CachePeer.
23 class HierarchyLogEntry
24 {
25
26 public:
27 HierarchyLogEntry();
28
29 /// Start recording new origin server or cache peer connection details.
30 /// Call this when trying to connect to a peer.
31 void resetPeerNotes(const Comm::ConnectionPointer &server, const char *requestedHost);
32
33 /// Account for a TCP peer read. Maintains peer response time stats (%<pt).
34 /// Call this after each successful peer socket read(2).
35 void notePeerRead();
36
37 /// Account for a TCP peer write. Maintains peer response time stats (%<pt).
38 /// Call this after each peer socket write(2), including failed ones.
39 void notePeerWrite();
40
41 /// Estimates response generation and sending delay at the last peer.
42 /// \returns whether the estimate (stored in `responseTime`) is available.
43 bool peerResponseTime(struct timeval &responseTime);
44
45 public:
46 hier_code code;
47 char host[SQUIDHOSTNAMELEN];
48 ping_data ping;
49 char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */
50 lookup_t cd_lookup; /* cd prediction: none, miss, hit */
51 int n_choices; /* #peers we selected from (cd only) */
52 int n_ichoices; /* #peers with known rtt we selected from (cd only) */
53
54 struct timeval peer_select_start;
55
56 struct timeval store_complete_stop;
57
58 Http::StatusCode peer_reply_status; ///< last HTTP status code received
59 Comm::ConnectionPointer tcpServer; ///< TCP/IP level details of the last peer/server connection
60 int64_t bodyBytesRead; ///< number of body bytes received from the next hop or -1
61
62 /// cumulative time spent (so far) communicating with all peers (see %<tt)
63 Stopwatch totalPeeringTime;
64
65 private:
66 void clearPeerNotes();
67
68 struct timeval peer_last_read_; ///< time of the last read from the last peer
69 struct timeval peer_last_write_; ///< time of the last write to the last peer
70 };
71
72 #endif /* SQUID_SRC_HIERARCHYLOGENTRY_H */
73