diff -u -r -N squid-6.8/ChangeLog squid-6.9/ChangeLog
--- squid-6.8/ChangeLog	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/ChangeLog	2024-04-08 05:02:07.000000000 +0000
@@ -1,3 +1,12 @@
+Changes in squid-6.9 (7 Apr 2024)
+	- Regression Bug 5349: basic_nis_auth build error: unterminated #ifndef
+	- Bug 5069: Keep listening after getsockname() error
+	- Bug 5360: FwdState::noteDestinationsEnd() assertion "err"
+	- Reduce stale errno usage
+	- Plug memory leak in handling cache manager requests
+	- Fix error: template-id not allowed for constructor in C++20
+	- Improve release packaging automation
+
 Changes in squid-6.8 (4 Mar 2024)
 
 	- Bug 5344: mgr:config segfaults without logformat
diff -u -r -N squid-6.8/configure squid-6.9/configure
--- squid-6.8/configure	2024-03-04 05:50:28.000000000 +0000
+++ squid-6.9/configure	2024-04-08 05:54:08.000000000 +0000
@@ -1,7 +1,7 @@
 #! /bin/sh
 # From configure.ac Revision.
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for Squid Web Proxy 6.8.
+# Generated by GNU Autoconf 2.71 for Squid Web Proxy 6.9.
 #
 # Report bugs to <https://bugs.squid-cache.org/>.
 #
@@ -626,8 +626,8 @@
 # Identity of this package.
 PACKAGE_NAME='Squid Web Proxy'
 PACKAGE_TARNAME='squid'
-PACKAGE_VERSION='6.8'
-PACKAGE_STRING='Squid Web Proxy 6.8'
+PACKAGE_VERSION='6.9'
+PACKAGE_STRING='Squid Web Proxy 6.9'
 PACKAGE_BUGREPORT='https://bugs.squid-cache.org/'
 PACKAGE_URL=''
 
@@ -1695,7 +1695,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Squid Web Proxy 6.8 to adapt to many kinds of systems.
+\`configure' configures Squid Web Proxy 6.9 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1766,7 +1766,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Squid Web Proxy 6.8:";;
+     short | recursive ) echo "Configuration of Squid Web Proxy 6.9:";;
    esac
   cat <<\_ACEOF
 
@@ -2186,7 +2186,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Squid Web Proxy configure 6.8
+Squid Web Proxy configure 6.9
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -3199,7 +3199,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Squid Web Proxy $as_me 6.8, which was
+It was created by Squid Web Proxy $as_me 6.9, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -4691,7 +4691,7 @@
 
 # Define the identity of the package.
  PACKAGE='squid'
- VERSION='6.8'
+ VERSION='6.9'
 
 
 printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -56708,7 +56708,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Squid Web Proxy $as_me 6.8, which was
+This file was extended by Squid Web Proxy $as_me 6.9, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -56776,7 +56776,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-Squid Web Proxy config.status 6.8
+Squid Web Proxy config.status 6.9
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
diff -u -r -N squid-6.8/configure.ac squid-6.9/configure.ac
--- squid-6.8/configure.ac	2024-03-04 05:50:28.000000000 +0000
+++ squid-6.9/configure.ac	2024-04-08 05:54:08.000000000 +0000
@@ -5,7 +5,7 @@
 ## Please see the COPYING and CONTRIBUTORS files for details.
 ##
 
-AC_INIT([Squid Web Proxy],[6.8],[https://bugs.squid-cache.org/],[squid])
+AC_INIT([Squid Web Proxy],[6.9],[https://bugs.squid-cache.org/],[squid])
 AC_PREREQ(2.61)
 AC_CONFIG_HEADERS([include/autoconf.h])
 AC_CONFIG_AUX_DIR(cfgaux)
diff -u -r -N squid-6.8/doc/release-notes/release-6.html squid-6.9/doc/release-notes/release-6.html
--- squid-6.8/doc/release-notes/release-6.html	2024-03-04 06:02:37.000000000 +0000
+++ squid-6.9/doc/release-notes/release-6.html	2024-04-08 06:05:38.000000000 +0000
@@ -3,10 +3,10 @@
 <HEAD>
  <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.82">
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <TITLE>Squid 6.8 release notes</TITLE>
+ <TITLE>Squid 6.9 release notes</TITLE>
 </HEAD>
 <BODY>
-<H1>Squid 6.8 release notes</H1>
+<H1>Squid 6.9 release notes</H1>
 
 <H2>Squid Developers</H2>
 <P>
@@ -59,7 +59,7 @@
 <HR>
 <H2><A NAME="s1">1.</A> <A HREF="#toc1">Notice</A></H2>
 
-<P>The Squid Team are pleased to announce the release of Squid-6.8 for testing.</P>
+<P>The Squid Team are pleased to announce the release of Squid-6.9 for testing.</P>
 <P>This new release is available for download from 
 <A HREF="http://www.squid-cache.org/Versions/v6/">http://www.squid-cache.org/Versions/v6/</A> or the
 <A HREF="http://www.squid-cache.org/Download/http-mirrors.html">mirrors</A>.</P>
diff -u -r -N squid-6.8/include/splay.h squid-6.9/include/splay.h
--- squid-6.8/include/splay.h	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/include/splay.h	2024-04-08 05:02:07.000000000 +0000
@@ -23,7 +23,7 @@
     typedef void SPLAYWALKEE(Value const & nodedata, void *state);
     static void DefaultFree (Value &aValue) {delete aValue;}
 
-    SplayNode<V> (Value const &);
+    SplayNode(const Value &);
     Value data;
     mutable SplayNode<V> *left;
     mutable SplayNode<V> *right;
diff -u -r -N squid-6.8/include/version.h squid-6.9/include/version.h
--- squid-6.8/include/version.h	2024-03-04 05:50:28.000000000 +0000
+++ squid-6.9/include/version.h	2024-04-08 05:54:08.000000000 +0000
@@ -10,7 +10,7 @@
 #define SQUID_INCLUDE_VERSION_H
 
 #ifndef SQUID_RELEASE_TIME
-#define SQUID_RELEASE_TIME 1709531399
+#define SQUID_RELEASE_TIME 1712555627
 #endif
 
 /*
diff -u -r -N squid-6.8/RELEASENOTES.html squid-6.9/RELEASENOTES.html
--- squid-6.8/RELEASENOTES.html	2024-03-04 06:02:37.000000000 +0000
+++ squid-6.9/RELEASENOTES.html	2024-04-08 06:05:38.000000000 +0000
@@ -3,10 +3,10 @@
 <HEAD>
  <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.82">
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <TITLE>Squid 6.8 release notes</TITLE>
+ <TITLE>Squid 6.9 release notes</TITLE>
 </HEAD>
 <BODY>
-<H1>Squid 6.8 release notes</H1>
+<H1>Squid 6.9 release notes</H1>
 
 <H2>Squid Developers</H2>
 <P>
@@ -59,7 +59,7 @@
 <HR>
 <H2><A NAME="s1">1.</A> <A HREF="#toc1">Notice</A></H2>
 
-<P>The Squid Team are pleased to announce the release of Squid-6.8 for testing.</P>
+<P>The Squid Team are pleased to announce the release of Squid-6.9 for testing.</P>
 <P>This new release is available for download from 
 <A HREF="http://www.squid-cache.org/Versions/v6/">http://www.squid-cache.org/Versions/v6/</A> or the
 <A HREF="http://www.squid-cache.org/Download/http-mirrors.html">mirrors</A>.</P>
diff -u -r -N squid-6.8/src/acl/external/delayer/ext_delayer_acl.8 squid-6.9/src/acl/external/delayer/ext_delayer_acl.8
--- squid-6.8/src/acl/external/delayer/ext_delayer_acl.8	2024-03-04 06:02:48.000000000 +0000
+++ squid-6.9/src/acl/external/delayer/ext_delayer_acl.8	2024-04-08 06:05:44.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_DELAYER_ACL 8"
-.TH EXT_DELAYER_ACL 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH EXT_DELAYER_ACL 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8 squid-6.9/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8
--- squid-6.8/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8	2024-03-04 06:02:49.000000000 +0000
+++ squid-6.9/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8	2024-04-08 06:05:44.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_KERBEROS_SID_GROUP_ACL 8"
-.TH EXT_KERBEROS_SID_GROUP_ACL 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH EXT_KERBEROS_SID_GROUP_ACL 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/acl/external/SQL_session/ext_sql_session_acl.8 squid-6.9/src/acl/external/SQL_session/ext_sql_session_acl.8
--- squid-6.8/src/acl/external/SQL_session/ext_sql_session_acl.8	2024-03-04 06:02:50.000000000 +0000
+++ squid-6.9/src/acl/external/SQL_session/ext_sql_session_acl.8	2024-04-08 06:05:44.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_SQL_SESSION_ACL 8"
-.TH EXT_SQL_SESSION_ACL 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH EXT_SQL_SESSION_ACL 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8 squid-6.9/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8
--- squid-6.8/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8	2024-03-04 06:02:50.000000000 +0000
+++ squid-6.9/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8	2024-04-08 06:05:44.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_WBINFO_GROUP_ACL 8"
-.TH EXT_WBINFO_GROUP_ACL 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH EXT_WBINFO_GROUP_ACL 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/auth/basic/DB/basic_db_auth.8 squid-6.9/src/auth/basic/DB/basic_db_auth.8
--- squid-6.8/src/auth/basic/DB/basic_db_auth.8	2024-03-04 06:02:55.000000000 +0000
+++ squid-6.9/src/auth/basic/DB/basic_db_auth.8	2024-04-08 06:05:46.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "BASIC_DB_AUTH 8"
-.TH BASIC_DB_AUTH 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH BASIC_DB_AUTH 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/auth/basic/NIS/nis_support.h squid-6.9/src/auth/basic/NIS/nis_support.h
--- squid-6.8/src/auth/basic/NIS/nis_support.h	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/auth/basic/NIS/nis_support.h	2024-04-08 05:02:07.000000000 +0000
@@ -8,9 +8,6 @@
 #ifndef SQUID_SRC_AUTH_BASIC_NIS_NIS_SUPPORT_H
 #define SQUID_SRC_AUTH_BASIC_NIS_NIS_SUPPORT_H
 
-#ifndef SQUID_SRC_AUTH_BASIC_NIS_NIS_SUPPORT_H
-#define SQUID_SRC_AUTH_BASIC_NIS_NIS_SUPPORT_H
-
 extern char * get_nis_password(char *user, char *nisdomain, char *nismap);
 
 #endif /* SQUID_SRC_AUTH_BASIC_NIS_NIS_SUPPORT_H */
diff -u -r -N squid-6.8/src/auth/basic/POP3/basic_pop3_auth.8 squid-6.9/src/auth/basic/POP3/basic_pop3_auth.8
--- squid-6.8/src/auth/basic/POP3/basic_pop3_auth.8	2024-03-04 06:02:56.000000000 +0000
+++ squid-6.9/src/auth/basic/POP3/basic_pop3_auth.8	2024-04-08 06:05:47.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "BASIC_POP3_AUTH 8"
-.TH BASIC_POP3_AUTH 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH BASIC_POP3_AUTH 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/cache_manager.cc squid-6.9/src/cache_manager.cc
--- squid-6.8/src/cache_manager.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/cache_manager.cc	2024-04-08 05:02:07.000000000 +0000
@@ -484,13 +484,13 @@
         response.header.putExt("Access-Control-Expose-Headers", "Server");
     }
 
-    std::unique_ptr<HttpHdrCc> cc(new HttpHdrCc());
+    HttpHdrCc cc;
     // this is honored by more caches but allows pointless revalidation;
     // revalidation will always fail because we do not support it (yet?)
-    cc->noCache(String());
+    cc.noCache(String());
     // this is honored by fewer caches but prohibits pointless revalidation
-    cc->noStore(true);
-    response.putCc(cc.release());
+    cc.noStore(true);
+    response.putCc(cc);
 }
 
 CacheManager*
diff -u -r -N squid-6.8/src/comm/TcpAcceptor.cc squid-6.9/src/comm/TcpAcceptor.cc
--- squid-6.8/src/comm/TcpAcceptor.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/comm/TcpAcceptor.cc	2024-04-08 05:02:07.000000000 +0000
@@ -381,7 +381,10 @@
     if (getsockname(sock, gai->ai_addr, &gai->ai_addrlen) != 0) {
         int xerrno = errno;
         Ip::Address::FreeAddr(gai);
-        throw TextException(ToSBuf("getsockname() failed to locate local-IP on ", details, ": ", xstrerr(xerrno)), Here());
+        debugs(50, DBG_IMPORTANT, "ERROR: Closing accepted TCP connection after failing to obtain its local IP address" <<
+               Debug::Extra << "accepted connection: " << details <<
+               Debug::Extra << "getsockname(2) error: " << xstrerr(xerrno));
+        return false;
     }
     details->local = *gai;
     Ip::Address::FreeAddr(gai);
diff -u -r -N squid-6.8/src/comm.cc squid-6.9/src/comm.cc
--- squid-6.8/src/comm.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/comm.cc	2024-04-08 05:02:07.000000000 +0000
@@ -378,7 +378,7 @@
     debugs(50, 3, "comm_openex: Attempt open socket for: " << addr );
 
     new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
-    int xerrno = errno;
+    const auto firstErrNo = errno;
 
     /* under IPv6 there is the possibility IPv6 is present but disabled. */
     /* try again as IPv4-native if possible */
@@ -391,6 +391,8 @@
         AI->ai_protocol = proto;
         debugs(50, 3, "Attempt fallback open socket for: " << addr );
         new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
+        // TODO: Report failures of this second socket() call.
+        // if both socket() calls fail, we use firstErrNo
         debugs(50, 2, "attempt open " << note << " socket on: " << addr);
     }
 
@@ -399,16 +401,16 @@
          * are failing because the open file table is full.  This
          * limits the number of simultaneous clients */
 
-        if (limitError(errno)) {
-            debugs(50, DBG_IMPORTANT, MYNAME << "socket failure: " << xstrerr(xerrno));
+        if (limitError(firstErrNo)) {
+            debugs(50, DBG_IMPORTANT, MYNAME << "socket failure: " << xstrerr(firstErrNo));
             fdAdjustReserved();
         } else {
-            debugs(50, DBG_CRITICAL, MYNAME << "socket failure: " << xstrerr(xerrno));
+            debugs(50, DBG_CRITICAL, MYNAME << "socket failure: " << xstrerr(firstErrNo));
         }
 
         Ip::Address::FreeAddr(AI);
 
-        errno = xerrno; // restore for caller
+        errno = firstErrNo; // restore for caller
         return -1;
     }
 
@@ -434,7 +436,9 @@
 
     // XXX transition only. prevent conn from closing the new FD on function exit.
     conn->fd = -1;
-    errno = xerrno; // restore for caller
+    // XXX: firstErrNo is not applicable here -- socket() calls succeeded above!
+    // TODO: Stop reporting error codes via errno.
+    errno = firstErrNo;
     return new_socket;
 }
 
@@ -890,11 +894,11 @@
     // notify read/write handlers after canceling select reservations, if any
     if (COMMIO_FD_WRITECB(fd)->active()) {
         Comm::SetSelect(fd, COMM_SELECT_WRITE, nullptr, nullptr, 0);
-        COMMIO_FD_WRITECB(fd)->finish(Comm::ERR_CLOSING, errno);
+        COMMIO_FD_WRITECB(fd)->finish(Comm::ERR_CLOSING, 0);
     }
     if (COMMIO_FD_READCB(fd)->active()) {
         Comm::SetSelect(fd, COMM_SELECT_READ, nullptr, nullptr, 0);
-        COMMIO_FD_READCB(fd)->finish(Comm::ERR_CLOSING, errno);
+        COMMIO_FD_READCB(fd)->finish(Comm::ERR_CLOSING, 0);
     }
 
 #if USE_DELAY_POOLS
diff -u -r -N squid-6.8/src/fs_io.cc squid-6.9/src/fs_io.cc
--- squid-6.8/src/fs_io.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/fs_io.cc	2024-04-08 05:02:07.000000000 +0000
@@ -211,6 +211,7 @@
     len = FD_WRITE_METHOD(fd,
                           fdd->write_q->buf + fdd->write_q->buf_offset,
                           fdd->write_q->len - fdd->write_q->buf_offset);
+    const auto xerrno = errno;
 
     debugs(6, 3, "diskHandleWrite: FD " << fd << " len = " << len);
 
@@ -219,9 +220,8 @@
     fd_bytes(fd, len, FD_WRITE);
 
     if (len < 0) {
-        if (!ignoreErrno(errno)) {
-            status = errno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR;
-            int xerrno = errno;
+        if (!ignoreErrno(xerrno)) {
+            status = xerrno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR;
             debugs(50, DBG_IMPORTANT, "ERROR: diskHandleWrite: FD " << fd << ": disk write failure: " << xstrerr(xerrno));
 
             /*
@@ -494,7 +494,7 @@
         return true;
 
     int xerrno = errno;
-    debugs(21, (errno == ENOENT ? 2 : DBG_IMPORTANT), "ERROR: Cannot rename " << from << " to " << to << ": " << xstrerr(xerrno));
+    debugs(21, (xerrno == ENOENT ? 2 : DBG_IMPORTANT), "ERROR: Cannot rename " << from << " to " << to << ": " << xstrerr(xerrno));
 
     return false;
 }
diff -u -r -N squid-6.8/src/ftp/Elements.cc squid-6.9/src/ftp/Elements.cc
--- squid-6.8/src/ftp/Elements.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/ftp/Elements.cc	2024-04-08 05:02:07.000000000 +0000
@@ -40,7 +40,7 @@
     {
         HttpHdrCc cc;
         cc.Private(String());
-        header.putCc(&cc);
+        header.putCc(cc);
     }
     if (ftpStatus > 0)
         header.putInt(Http::HdrType::FTP_STATUS, ftpStatus);
diff -u -r -N squid-6.8/src/FwdState.cc squid-6.9/src/FwdState.cc
--- squid-6.8/src/FwdState.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/FwdState.cc	2024-04-08 05:02:07.000000000 +0000
@@ -657,7 +657,13 @@
     }
 
     // destinationsFound, but none of them worked, and we were waiting for more
-    assert(err);
+    debugs(17, 7, "no more destinations to try after " << n_tries << " failed attempts");
+    if (!err) {
+        const auto finalError = new ErrorState(ERR_CANNOT_FORWARD, Http::scBadGateway, request, al);
+        static const auto d = MakeNamedErrorDetail("REFORWARD_TO_NONE");
+        finalError->detailError(d);
+        fail(finalError);
+    } // else use actual error from last forwarding attempt
     stopAndDestroy("all found paths have failed");
 }
 
diff -u -r -N squid-6.8/src/http/Message.cc squid-6.9/src/http/Message.cc
--- squid-6.8/src/http/Message.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/http/Message.cc	2024-04-08 05:02:07.000000000 +0000
@@ -30,22 +30,11 @@
 }
 
 void
-Http::Message::putCc(const HttpHdrCc *otherCc)
+Http::Message::putCc(const HttpHdrCc &otherCc)
 {
-    // get rid of the old CC, if any
-    if (cache_control) {
-        delete cache_control;
-        cache_control = nullptr;
-        if (!otherCc)
-            header.delById(Http::HdrType::CACHE_CONTROL);
-        // else it will be deleted inside putCc() below
-    }
-
-    // add new CC, if any
-    if (otherCc) {
-        cache_control = new HttpHdrCc(*otherCc);
-        header.putCc(cache_control);
-    }
+    delete cache_control;
+    cache_control = new HttpHdrCc(otherCc);
+    header.putCc(*cache_control);
 }
 
 /* find first CRLF */
diff -u -r -N squid-6.8/src/http/Message.h squid-6.9/src/http/Message.h
--- squid-6.8/src/http/Message.h	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/http/Message.h	2024-04-08 05:02:07.000000000 +0000
@@ -98,8 +98,9 @@
 
     uint32_t sources = 0; ///< The message sources
 
-    /// copies Cache-Control header to this message
-    void putCc(const HttpHdrCc *otherCc);
+    /// copies Cache-Control header to this message,
+    /// overwriting existing Cache-Control header(s), if any
+    void putCc(const HttpHdrCc &);
 
     // returns true and sets hdr_sz on success
     // returns false and sets *error to zero when needs more data
diff -u -r -N squid-6.8/src/http/url_rewriters/LFS/url_lfs_rewrite.8 squid-6.9/src/http/url_rewriters/LFS/url_lfs_rewrite.8
--- squid-6.8/src/http/url_rewriters/LFS/url_lfs_rewrite.8	2024-03-04 06:02:59.000000000 +0000
+++ squid-6.9/src/http/url_rewriters/LFS/url_lfs_rewrite.8	2024-04-08 06:05:48.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "URL_LFS_REWRITE 8"
-.TH URL_LFS_REWRITE 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH URL_LFS_REWRITE 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/http.cc squid-6.9/src/http.cc
--- squid-6.8/src/http.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/http.cc	2024-04-08 05:02:07.000000000 +0000
@@ -2032,7 +2032,7 @@
         if (flags.only_if_cached)
             cc->onlyIfCached(true);
 
-        hdr_out->putCc(cc);
+        hdr_out->putCc(*cc);
 
         delete cc;
     }
diff -u -r -N squid-6.8/src/HttpHeader.cc squid-6.9/src/HttpHeader.cc
--- squid-6.8/src/HttpHeader.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/HttpHeader.cc	2024-04-08 05:02:07.000000000 +0000
@@ -1040,15 +1040,14 @@
 }
 
 void
-HttpHeader::putCc(const HttpHdrCc * cc)
+HttpHeader::putCc(const HttpHdrCc &cc)
 {
-    assert(cc);
     /* remove old directives if any */
     delById(Http::HdrType::CACHE_CONTROL);
     /* pack into mb */
     MemBuf mb;
     mb.init();
-    cc->packInto(&mb);
+    cc.packInto(&mb);
     /* put */
     addEntry(new HttpHeaderEntry(Http::HdrType::CACHE_CONTROL, SBuf(), mb.buf));
     /* cleanup */
diff -u -r -N squid-6.8/src/HttpHeader.h squid-6.9/src/HttpHeader.h
--- squid-6.8/src/HttpHeader.h	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/HttpHeader.h	2024-04-08 05:02:07.000000000 +0000
@@ -137,7 +137,7 @@
     void putTime(Http::HdrType id, time_t htime);
     void putStr(Http::HdrType id, const char *str);
     void putAuth(const char *auth_scheme, const char *realm);
-    void putCc(const HttpHdrCc * cc);
+    void putCc(const HttpHdrCc &cc);
     void putContRange(const HttpHdrContRange * cr);
     void putRange(const HttpHdrRange * range);
     void putSc(HttpHdrSc *sc);
diff -u -r -N squid-6.8/src/HttpReply.cc squid-6.9/src/HttpReply.cc
--- squid-6.8/src/HttpReply.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/HttpReply.cc	2024-04-08 05:02:07.000000000 +0000
@@ -148,7 +148,8 @@
             rv->header.addEntry(e->clone());
     }
 
-    rv->putCc(cache_control);
+    if (cache_control)
+        rv->putCc(*cache_control);
 
     /* rv->body */
     return rv;
diff -u -r -N squid-6.8/src/log/DB/log_db_daemon.8 squid-6.9/src/log/DB/log_db_daemon.8
--- squid-6.8/src/log/DB/log_db_daemon.8	2024-03-04 06:03:00.000000000 +0000
+++ squid-6.9/src/log/DB/log_db_daemon.8	2024-04-08 06:05:49.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "LOG_DB_DAEMON 8"
-.TH LOG_DB_DAEMON 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH LOG_DB_DAEMON 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/mime.cc squid-6.9/src/mime.cc
--- squid-6.8/src/mime.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/mime.cc	2024-04-08 05:02:07.000000000 +0000
@@ -421,7 +421,7 @@
         reply->setHeaders(status, nullptr, mimeGetContentType(icon_.c_str()), sb.st_size, sb.st_mtime, -1);
     reply->cache_control = new HttpHdrCc();
     reply->cache_control->maxAge(86400);
-    reply->header.putCc(reply->cache_control);
+    reply->header.putCc(*reply->cache_control);
     e->replaceHttpReply(reply.getRaw());
 
     if (status == Http::scOkay) {
diff -u -r -N squid-6.8/src/security/cert_validators/fake/security_fake_certverify.8 squid-6.9/src/security/cert_validators/fake/security_fake_certverify.8
--- squid-6.8/src/security/cert_validators/fake/security_fake_certverify.8	2024-03-04 06:03:03.000000000 +0000
+++ squid-6.9/src/security/cert_validators/fake/security_fake_certverify.8	2024-04-08 06:05:50.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "SECURITY_FAKE_CERTVERIFY 8"
-.TH SECURITY_FAKE_CERTVERIFY 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH SECURITY_FAKE_CERTVERIFY 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/store/id_rewriters/file/storeid_file_rewrite.8 squid-6.9/src/store/id_rewriters/file/storeid_file_rewrite.8
--- squid-6.8/src/store/id_rewriters/file/storeid_file_rewrite.8	2024-03-04 06:02:52.000000000 +0000
+++ squid-6.9/src/store/id_rewriters/file/storeid_file_rewrite.8	2024-04-08 06:05:45.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "STOREID_FILE_REWRITE 8"
-.TH STOREID_FILE_REWRITE 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH STOREID_FILE_REWRITE 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-6.8/src/tests/stub_HttpHeader.cc squid-6.9/src/tests/stub_HttpHeader.cc
--- squid-6.8/src/tests/stub_HttpHeader.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/tests/stub_HttpHeader.cc	2024-04-08 05:02:07.000000000 +0000
@@ -59,7 +59,7 @@
 void HttpHeader::putTime(Http::HdrType, time_t) STUB
 void HttpHeader::putStr(Http::HdrType, const char *) STUB
 void HttpHeader::putAuth(const char *, const char *) STUB
-void HttpHeader::putCc(const HttpHdrCc *) STUB
+void HttpHeader::putCc(const HttpHdrCc &) STUB
 void HttpHeader::putContRange(const HttpHdrContRange *) STUB
 void HttpHeader::putRange(const HttpHdrRange *) STUB
 void HttpHeader::putSc(HttpHdrSc *) STUB
diff -u -r -N squid-6.8/src/tests/stub_libhttp.cc squid-6.9/src/tests/stub_libhttp.cc
--- squid-6.8/src/tests/stub_libhttp.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/tests/stub_libhttp.cc	2024-04-08 05:02:07.000000000 +0000
@@ -42,7 +42,7 @@
 void Message::packInto(Packable *, bool) const STUB
 void Message::setContentLength(int64_t) STUB
 bool Message::persistent() const STUB_RETVAL(false)
-void Message::putCc(const HttpHdrCc *) STUB
+void Message::putCc(const HttpHdrCc &) STUB
 bool Message::parse(const char *, const size_t, bool, Http::StatusCode *) STUB_RETVAL(false)
 bool Message::parseCharBuf(const char *, ssize_t) STUB_RETVAL(false)
 int Message::httpMsgParseStep(const char *, int, int) STUB_RETVAL(-1)
diff -u -r -N squid-6.8/src/tunnel.cc squid-6.9/src/tunnel.cc
--- squid-6.8/src/tunnel.cc	2024-03-04 05:45:51.000000000 +0000
+++ squid-6.9/src/tunnel.cc	2024-04-08 05:02:07.000000000 +0000
@@ -1364,7 +1364,15 @@
     }
 
     // destinationsFound, but none of them worked, and we were waiting for more
-    assert(savedError);
+    debugs(17, 7, "no more destinations to try after " << n_tries << " failed attempts");
+    if (!savedError) {
+        // retryOrBail() must be preceded by saveError(), but in case we forgot:
+        const auto finalError = new ErrorState(ERR_CANNOT_FORWARD, Http::scBadGateway, request.getRaw(), al);
+        static const auto d = MakeNamedErrorDetail("RETRY_TO_NONE");
+        finalError->detailError(d);
+        saveError(finalError);
+    } // else use actual error from last forwarding attempt
+
     // XXX: Honor clientExpectsConnectResponse() before replying.
     sendError(savedError, "all found paths have failed");
 }
diff -u -r -N squid-6.8/tools/helper-mux/helper-mux.8 squid-6.9/tools/helper-mux/helper-mux.8
--- squid-6.8/tools/helper-mux/helper-mux.8	2024-03-04 06:03:05.000000000 +0000
+++ squid-6.9/tools/helper-mux/helper-mux.8	2024-04-08 06:05:51.000000000 +0000
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "HELPER-MUX 8"
-.TH HELPER-MUX 8 "2024-03-04" "perl v5.34.0" "User Contributed Perl Documentation"
+.TH HELPER-MUX 8 "2024-04-08" "perl v5.34.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
