#ifndef SQUID_HTTPACCESSLOGENTRY_H
#define SQUID_HTTPACCESSLOGENTRY_H
+#include "comm/Connection.h"
#include "HttpVersion.h"
#include "HttpRequestMethod.h"
#include "HierarchyLogEntry.h"
{
public:
- AccessLogEntry() : url(NULL) , reply(NULL), request(NULL),
+ AccessLogEntry() : url(NULL), tcpClient(), reply(NULL), request(NULL),
adapted_request(NULL) {}
const char *url;
+ /// TCP/IP level details about the client connection
+ Comm::ConnectionPointer tcpClient;
+ // TCP/IP level details about the server or peer connection
+ // are stored in hier.tcpServer
+
/** \brief This subclass holds log info for HTTP protocol
* \todo Inner class declarations should be moved outside
* \todo details of HTTP held in the parent class need moving into here.
#ifndef SQUID_HTTPHIERARCHYLOGENTRY_H
#define SQUID_HTTPHIERARCHYLOGENTRY_H
+#include "comm/Connection.h"
#include "hier_code.h"
-#include "ip/Address.h"
#include "lookup_t.h"
#include "rfc2181.h"
#include "PingData.h"
public:
HierarchyLogEntry();
+ ~HierarchyLogEntry() { tcpServer = NULL; };
+
+ /// Record details from a new server connection.
+ /// call this whenever the destination server changes.
+ void note(const Comm::ConnectionPointer &server, const char *requestedHost);
+
+public:
hier_code code;
char host[SQUIDHOSTNAMELEN];
ping_data ping;
int64_t peer_response_time; ///< last peer response delay
timeval first_conn_start; ///< first connection use among all peers
int64_t total_response_time; ///< cumulative for all peers
- Ip::Address peer_local_addr; ///< local IP:port of the last server-side connection
+ Comm::ConnectionPointer tcpServer; ///< TCP/IP level details of the last server-side connection
int64_t bodyBytesRead; ///< number of body bytes received from the next hop or -1
};
-extern void hierarchyNote(HierarchyLogEntry *, hier_code, const char *);
-
#endif /* SQUID_HTTPHIERARCHYLOGENTRY_H */
{
start_time = current_time;
setConn(aConn);
- clientConnection = aConn->clientConnection;
+ al.tcpClient = clientConnection = aConn->clientConnection;
dlinkAdd(this, &active, &ClientActiveRequests);
#if USE_ADAPTATION
request_satisfaction_mode = false;
/* case LFT_SERVER_PORT: */
case LFT_LOCAL_IP:
- if (al->request) {
- out = al->request->my_addr.NtoA(tmp,sizeof(tmp));
+ if (al->tcpClient != NULL) {
+ out = al->tcpClient->local.NtoA(tmp,sizeof(tmp));
}
-
break;
case LFT_LOCAL_PORT:
- if (al->request) {
- outint = al->request->my_addr.GetPort();
+ if (al->tcpClient != NULL) {
+ outint = al->tcpClient->local.GetPort();
doint = 1;
}
-
break;
// the fmt->type can not be LFT_PEER_LOCAL_IP_OLD_27
// but compiler complains if ommited
case LFT_PEER_LOCAL_IP_OLD_27:
case LFT_PEER_LOCAL_IP:
- if (!al->hier.peer_local_addr.IsAnyAddr()) {
- out = al->hier.peer_local_addr.NtoA(tmp,sizeof(tmp));
+ if (al->hier.tcpServer != NULL) {
+ out = al->hier.tcpServer->local.NtoA(tmp,sizeof(tmp));
}
break;
case LFT_PEER_LOCAL_PORT:
- if ((outint = al->hier.peer_local_addr.GetPort())) {
+ if (al->hier.tcpServer != NULL) {
+ outint = al->hier.tcpServer->local.GetPort();
doint = 1;
}
serverConn = conn;
-#if REDUNDANT_NOW
- if (Config.onoff.log_ip_on_direct && serverConnection()->peerType == HIER_DIRECT)
- updateHierarchyInfo();
-#endif
-
debugs(17, 3, HERE << serverConnection() << ": '" << entry->url() << "'" );
comm_add_close_handler(serverConnection()->fd, fwdServerClosedWrapper, this);
FwdState::updateHierarchyInfo()
{
assert(request);
-
assert(serverDestinations.size() > 0);
- char nextHop[256];
-
- if (serverConnection()->getPeer()) {
- // went to peer, log peer host name
- snprintf(nextHop,256,"%s", serverConnection()->getPeer()->name);
- } else {
- // went DIRECT, must honor log_ip_on_direct
- if (!Config.onoff.log_ip_on_direct)
- snprintf(nextHop,256,"%s",request->GetHost()); // domain name
- else
- serverConnection()->remote.NtoA(nextHop, 256);
- }
-
- assert(nextHop[0]);
- hierarchyNote(&request->hier, serverConnection()->peerType, nextHop);
+ request->hier.note(serverConnection(), request->GetHost());
}
peer_reply_status(HTTP_STATUS_NONE),
peer_response_time(-1),
total_response_time(-1),
- peer_local_addr(),
+ tcpServer(NULL),
bodyBytesRead(-1)
{
memset(host, '\0', SQUIDHOSTNAMELEN);
}
void
-hierarchyNote(HierarchyLogEntry * hl,
- hier_code code,
- const char *cache_peer)
+HierarchyLogEntry::note(const Comm::ConnectionPointer &server, const char *requestedHost)
{
- assert(hl != NULL);
- hl->code = code;
- xstrncpy(hl->host, cache_peer, SQUIDHOSTNAMELEN);
+ tcpServer = server;
+ if (tcpServer == NULL) {
+ code = HIER_NONE;
+ xstrncpy(host, requestedHost, sizeof(host));
+ } else {
+ code = tcpServer->peerType;
+
+ if (tcpServer->getPeer()) {
+ // went to peer, log peer host name
+ xstrncpy(host, tcpServer->getPeer()->name, sizeof(host));
+ } else {
+ // went DIRECT, must honor log_ip_on_direct
+ if (!Config.onoff.log_ip_on_direct)
+ xstrncpy(host, requestedHost, sizeof(host));
+ else
+ tcpServer->remote.NtoA(host, 256);
+ }
+ }
}
static void
tunnelState->server.setDelayId(DelayId());
#endif
- if (conn != NULL && conn->getPeer())
- hierarchyNote(&tunnelState->request->hier, conn->peerType, conn->getPeer()->name);
- else if (Config.onoff.log_ip_on_direct) {
- conn->remote.NtoA(fd_table[conn->fd].ipaddr,sizeof(fd_table[conn->fd].ipaddr));
- hierarchyNote(&tunnelState->request->hier, conn->peerType, fd_table[conn->fd].ipaddr);
- } else
- hierarchyNote(&tunnelState->request->hier, conn->peerType, tunnelState->getHost());
-
+ tunnelState->request->hier.note(conn, tunnelState->getHost());
tunnelState->server.conn = conn;
tunnelState->request->peer_host = conn->getPeer() ? conn->getPeer()->host : NULL;