changeset 40876:dc9901558e3c

commandserver: extract handler of new socket connection This prepares for adding an IPC socket.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 31 Oct 2018 22:02:38 +0900
parents e7110f44ee2d
children 9f00de4dc7cb
files mercurial/commandserver.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commandserver.py	Wed Oct 31 21:57:11 2018 +0900
+++ b/mercurial/commandserver.py	Wed Oct 31 22:02:38 2018 +0900
@@ -565,11 +565,17 @@
                 if exiting:
                     break
                 continue
+            self._acceptnewconnection(self._sock, selector)
+        selector.close()
+
+    def _acceptnewconnection(self, sock, selector):
+        h = self._servicehandler
+        if True:
             try:
-                conn, _addr = self._sock.accept()
+                conn, _addr = sock.accept()
             except socket.error as inst:
                 if inst.args[0] == errno.EINTR:
-                    continue
+                    return
                 raise
 
             pid = os.fork()
@@ -584,7 +590,7 @@
             else:
                 try:
                     selector.close()
-                    self._sock.close()
+                    sock.close()
                     self._runworker(conn)
                     conn.close()
                     os._exit(0)
@@ -593,7 +599,6 @@
                         self.ui.traceback(force=True)
                     finally:
                         os._exit(255)
-        selector.close()
 
     def _sigchldhandler(self, signal, frame):
         self._reapworkers(os.WNOHANG)