changeset 30919:a95fc01aaffe

commandserver: prevent unlink socket twice This patch changes unixforkingservice so it only calls `self._servicehandler.unlinksocket(self.address)` at most once. This is needed by the next patch.
author Jun Wu <quark@fb.com>
date Wed, 08 Feb 2017 14:37:38 -0800
parents 2aaa8bfc7bd9
children b1b36c6499c2
files mercurial/commandserver.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commandserver.py	Thu Feb 09 05:57:54 2017 -0800
+++ b/mercurial/commandserver.py	Wed Feb 08 14:37:38 2017 -0800
@@ -447,6 +447,7 @@
         self._sock = None
         self._oldsigchldhandler = None
         self._workerpids = set()  # updated by signal handler; do not iterate
+        self._socketunlinked = None
 
     def init(self):
         self._sock = socket.socket(socket.AF_UNIX)
@@ -455,11 +456,17 @@
         o = signal.signal(signal.SIGCHLD, self._sigchldhandler)
         self._oldsigchldhandler = o
         self._servicehandler.printbanner(self.address)
+        self._socketunlinked = False
+
+    def _unlinksocket(self):
+        if not self._socketunlinked:
+            self._servicehandler.unlinksocket(self.address)
+            self._socketunlinked = True
 
     def _cleanup(self):
         signal.signal(signal.SIGCHLD, self._oldsigchldhandler)
         self._sock.close()
-        self._servicehandler.unlinksocket(self.address)
+        self._unlinksocket()
         # don't kill child processes as they have active clients, just wait
         self._reapworkers(0)