# HG changeset patch # User Valentin Gatien-Baron # Date 2021-02-15 19:15:02 # Node ID 0509cee38757ea336a9cdfa41a3d06962c46a238 # Parent 0738bc25d6acce9d92be34118f60f80955b9007b remotefilelog: rework workaround for sshpeer deadlocks The wrapping of `sshpeer.cleanup` silently broke when `cleanup` was renamed to `_cleanup`, a couple of years ago. I don't know what `orig.im_self` is, but regardless, the intention of the wrapping seems pretty clear: close stderr before sshpeer._cleanuppipes blocks on it. So do that. Differential Revision: https://phab.mercurial-scm.org/D9997 diff --git a/hgext/remotefilelog/connectionpool.py b/hgext/remotefilelog/connectionpool.py --- a/hgext/remotefilelog/connectionpool.py +++ b/hgext/remotefilelog/connectionpool.py @@ -43,17 +43,19 @@ class connectionpool(object): if conn is None: - def _cleanup(orig): - # close pipee first so peer.cleanup reading it won't deadlock, - # if there are other processes with pipeo open (i.e. us). - peer = orig.im_self - if util.safehasattr(peer, 'pipee'): - peer.pipee.close() - return orig() + peer = hg.peer(self._repo.ui, {}, path) + if util.safehasattr(peer, '_cleanup'): - peer = hg.peer(self._repo.ui, {}, path) - if util.safehasattr(peer, 'cleanup'): - extensions.wrapfunction(peer, b'cleanup', _cleanup) + class mypeer(peer.__class__): + def _cleanup(self): + # close pipee first so peer.cleanup reading it won't + # deadlock, if there are other processes with pipeo + # open (i.e. us). + if util.safehasattr(self, 'pipee'): + self.pipee.close() + return super(mypeer, self)._cleanup() + + peer.__class__ = mypeer conn = connection(pathpool, peer)