2 * Copyright (C) 1996-2023 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_SRC_HIERARCHYLOGENTRY_H
10 #define SQUID_SRC_HIERARCHYLOGENTRY_H
12 #include "base/Stopwatch.h"
13 #include "comm/Connection.h"
15 #include "hier_code.h"
16 #include "http/StatusCode.h"
21 /// Maintains peer selection details and peer I/O stats.
22 /// Here, "peer" is an origin server or CachePeer.
23 class HierarchyLogEntry
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
);
33 /// Account for a TCP peer read. Maintains peer response time stats (%<pt).
34 /// Call this after each successful peer socket read(2).
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.
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
);
47 char host
[SQUIDHOSTNAMELEN
];
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) */
54 struct timeval peer_select_start
;
56 struct timeval store_complete_stop
;
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
62 /// cumulative time spent (so far) communicating with all peers (see %<tt)
63 Stopwatch totalPeeringTime
;
66 void clearPeerNotes();
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
72 #endif /* SQUID_SRC_HIERARCHYLOGENTRY_H */