commandserver: extract handler of new socket connection
This prepares for adding an IPC socket.
--- 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)