From 6bd74111a80de08270dc5886e6ad6bcd7d5e08b4 Mon Sep 17 00:00:00 2001 From: Eduard Bagdasaryan Date: Sun, 24 Nov 2024 20:19:03 +0000 Subject: [PATCH] Do not TLS close_notify when resetting a TCP connection (#1944) --- src/comm.cc | 4 +++- src/fde.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/comm.cc b/src/comm.cc index c496b8aaa3a..24fe6ce462c 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -783,6 +783,8 @@ commConfigureLinger(const int fd, const OnOff enabled) l.l_onoff = (enabled == OnOff::on ? 1 : 0); l.l_linger = 0; // how long to linger for, in seconds + fd_table[fd].flags.harshClosureRequested = (l.l_onoff && !l.l_linger); // close(2) sends TCP RST if true + if (setsockopt(fd, SOL_SOCKET, SO_LINGER, reinterpret_cast(&l), sizeof(l)) < 0) { const auto xerrno = errno; debugs(50, DBG_CRITICAL, "ERROR: Failed to set closure behavior (SO_LINGER) for FD " << fd << ": " << xstrerr(xerrno)); @@ -877,7 +879,7 @@ _comm_close(int fd, char const *file, int line) // For simplicity sake, we remain in the caller's context while still // allowing individual advanced callbacks to overwrite it. - if (F->ssl) { + if (F->ssl && !F->flags.harshClosureRequested) { const auto startCall = asyncCall(5, 4, "commStartTlsClose", callDialer(commStartTlsClose, fd)); ScheduleCallHere(startCall); diff --git a/src/fde.h b/src/fde.h index 930edc08ed4..f58182eabe7 100644 --- a/src/fde.h +++ b/src/fde.h @@ -127,6 +127,8 @@ class fde bool read_pending = false; //bool write_pending; //XXX seems not to be used bool transparent = false; + /// whether comm_reset_close() (or old_comm_reset_close()) has been called + bool harshClosureRequested = false; } flags; int64_t bytes_read = 0;