From: Amos Jeffries Date: Sat, 4 Feb 2017 16:30:49 +0000 (+1300) Subject: Cleanup: remove unsused fd_debug_t and fdd_table X-Git-Tag: M-staged-PR71~285 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a5d9ea503e0760dbc9b93221a85ddcd22d0332e;p=thirdparty%2Fsquid.git Cleanup: remove unsused fd_debug_t and fdd_table This tables used to store the file and line location where each FD was closed from, but never read for any reports or logs. Make the cache.log debugging for comm_close display that information instead of storing it in memory. This way when debug of the comm layer is enabled the closure information for each FD open/close cycle is recorded and not just the place of last closure. Also we save a few hundred KB of memory this table was using and all the CPU cycles used to maintain it when debugging was not needed. --- diff --git a/src/comm.cc b/src/comm.cc index 1b62d7d19a..a1f4409eb1 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -82,8 +82,6 @@ static void commSetTcpNoDelay(int); #endif static void commSetTcpRcvbuf(int, int); -fd_debug_t *fdd_table = NULL; - bool isOpen(const int fd) { @@ -428,9 +426,6 @@ comm_init_opened(const Comm::ConnectionPointer &conn, assert(!isOpen(conn->fd)); // NP: global isOpen checks the fde entry for openness not the Comm::Connection fd_open(conn->fd, FD_SOCKET, note); - fdd_table[conn->fd].close_file = NULL; - fdd_table[conn->fd].close_line = 0; - fde *F = &fd_table[conn->fd]; F->local_addr = conn->local; @@ -862,13 +857,11 @@ comm_close_complete(const FdeCbParams ¶ms) void _comm_close(int fd, char const *file, int line) { - debugs(5, 3, "comm_close: start closing FD " << fd); + debugs(5, 3, "start closing FD " << fd << " by " << file << ":" << line); assert(fd >= 0); assert(fd < Squid_MaxFD); fde *F = &fd_table[fd]; - fdd_table[fd].close_file = file; - fdd_table[fd].close_line = line; if (F->closing()) return; @@ -1229,7 +1222,6 @@ void comm_init(void) { fd_table =(fde *) xcalloc(Squid_MaxFD, sizeof(fde)); - fdd_table = (fd_debug_t *)xcalloc(Squid_MaxFD, sizeof(fd_debug_t)); /* make sure the accept() socket FIFO delay queue exists */ Comm::AcceptLimiter::Instance(); @@ -1256,7 +1248,6 @@ comm_exit(void) TheHalfClosed = NULL; safe_free(fd_table); - safe_free(fdd_table); Comm::CallbackTableDestruct(); } @@ -1926,10 +1917,6 @@ comm_open_uds(int sock_type, assert(!isOpen(new_socket)); fd_open(new_socket, FD_MSGHDR, addr->sun_path); - fdd_table[new_socket].close_file = NULL; - - fdd_table[new_socket].close_line = 0; - fd_table[new_socket].sock_family = AI.ai_family; if (!(flags & COMM_NOCLOEXEC)) diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index 189f5a6849..ba77cb6191 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -407,9 +407,6 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) // so we end up with a uniform "(HTTP|FTP-data|HTTPS|...) remote-ip:remote-port" fd_open(sock, FD_SOCKET, "HTTP Request"); - fdd_table[sock].close_file = NULL; - fdd_table[sock].close_line = 0; - fde *F = &fd_table[sock]; details->remote.toStr(F->ipaddr,MAX_IPSTRLEN); F->remote_port = details->remote.port(); diff --git a/src/comm/comm_internal.h b/src/comm/comm_internal.h index f9f2013d8a..2062f4dcad 100644 --- a/src/comm/comm_internal.h +++ b/src/comm/comm_internal.h @@ -11,14 +11,6 @@ /* misc collection of bits shared by Comm code, but not needed by the rest of Squid. */ -struct _fd_debug_t { - char const *close_file; - int close_line; -}; - -typedef struct _fd_debug_t fd_debug_t; -extern fd_debug_t *fdd_table; - bool isOpen(const int fd); void commStopHalfClosedMonitor(int fd);