[Updated] D9206: posix: avoid a leaked file descriptor in a unix domain socket exception case
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Thu Oct 15 12:38:46 UTC 2020
Closed by commit rHG87c35b5a14eb: posix: avoid a leaked file descriptor in a unix domain socket exception case (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9206?vs=23205&id=23219
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9206/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9206
AFFECTED FILES
mercurial/posix.py
CHANGE DETAILS
diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -764,10 +764,14 @@
# platforms (see sys/un.h)
dirname, basename = os.path.split(path)
bakwdfd = None
- if dirname:
- bakwdfd = os.open(b'.', os.O_DIRECTORY)
- os.chdir(dirname)
- sock.bind(basename)
- if bakwdfd:
- os.fchdir(bakwdfd)
- os.close(bakwdfd)
+
+ try:
+ if dirname:
+ bakwdfd = os.open(b'.', os.O_DIRECTORY)
+ os.chdir(dirname)
+ sock.bind(basename)
+ if bakwdfd:
+ os.fchdir(bakwdfd)
+ finally:
+ if bakwdfd:
+ os.close(bakwdfd)
To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20201015/d94e837a/attachment-0002.html>
More information about the Mercurial-patches
mailing list