commandserver: move printbanner logic to bindsocket

bindsocket now handles listen automatically. "printbanner" seems to be just
a part of "bindsocket". This simplifies the interface a bit.
This commit is contained in:
Jun Wu 2017-04-30 11:21:05 -07:00
parent d3cc1e50f4
commit 15584f0091
2 changed files with 3 additions and 9 deletions

View File

@ -492,6 +492,7 @@ class chgunixservicehandler(object):
self._checkextensions()
self._bind(sock)
self._createsymlink()
# no "listening at" message should be printed to simulate hg behavior
def _inithashstate(self, address):
self._baseaddress = address
@ -546,10 +547,6 @@ class chgunixservicehandler(object):
# the client will start a new server on demand.
util.tryunlink(self._realaddress)
def printbanner(self, address):
# no "listening at" message should be printed to simulate hg behavior
pass
def shouldexit(self):
if not self._issocketowner():
self.ui.debug('%s is not owned, exiting.\n' % self._realaddress)

View File

@ -410,14 +410,12 @@ class unixservicehandler(object):
def bindsocket(self, sock, address):
util.bindunixsocket(sock, address)
sock.listen(socket.SOMAXCONN)
self.ui.status(_('listening at %s\n') % address)
self.ui.flush() # avoid buffering of status message
def unlinksocket(self, address):
os.unlink(address)
def printbanner(self, address):
self.ui.status(_('listening at %s\n') % address)
self.ui.flush() # avoid buffering of status message
def shouldexit(self):
"""True if server should shut down; checked per pollinterval"""
return False
@ -455,7 +453,6 @@ class unixforkingservice(object):
self._servicehandler.bindsocket(self._sock, self.address)
o = signal.signal(signal.SIGCHLD, self._sigchldhandler)
self._oldsigchldhandler = o
self._servicehandler.printbanner(self.address)
self._socketunlinked = False
def _unlinksocket(self):