changeset 49542:8251f7cc787d stable

keepalive: ensure `close_all()` actually closes all cached connections While debugging why LFS blob downloads are getting corrupted with workers, I noticed that prior to spinning up the workers, the ConnectionManager has 2 connections to the server and calling `KeepAliveHandler.close_all()` left one behind. The reason is the value component of `self._cm.get_all().items()` is a list, and `self._cm.remove()` modifies said list while the caller is iterating over it. Now `get_all()` is a deep copy of both the dict and lists in all cases.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 18 Oct 2022 11:54:58 -0400
parents bc2ecf08ae04
children 76fbb1b6692a
files mercurial/keepalive.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/keepalive.py	Wed Nov 02 16:46:46 2022 -0400
+++ b/mercurial/keepalive.py	Tue Oct 18 11:54:58 2022 -0400
@@ -166,7 +166,9 @@
         if host:
             return list(self._hostmap[host])
         else:
-            return dict(self._hostmap)
+            return dict(
+                {h: list(conns) for (h, conns) in self._hostmap.items()}
+            )
 
 
 class KeepAliveHandler: