]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not TLS close_notify when resetting a TCP connection (#1944)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sun, 24 Nov 2024 20:19:03 +0000 (20:19 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 24 Nov 2024 20:19:12 +0000 (20:19 +0000)
src/comm.cc
src/fde.h

index c496b8aaa3aa7d49340de9754fff97740d74f575..24fe6ce462c6d0ac63a890131c662084d1d57f2a 100644 (file)
@@ -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<char*>(&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);
index 930edc08ed43e0a46910d21692ceb2a9fecac5a3..f58182eabe7fe4887b0eb3ccd43a53d8d82d240a 100644 (file)
--- a/src/fde.h
+++ b/src/fde.h
@@ -127,6 +127,8 @@ public:
         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;