# HG changeset patch # User Matt Harbison # Date 2022-10-18 15:54:58 # Node ID 8251f7cc787db6f1b1edab5b836bfca187bdb942 # Parent bc2ecf08ae042d51805eeeef0d60eaa1c8181dbf 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. diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py --- a/mercurial/keepalive.py +++ b/mercurial/keepalive.py @@ -166,7 +166,9 @@ class ConnectionManager: 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: