Use listenOnUnused instead of allocate_tcp_port in create_log_tub

This commit is contained in:
Jean-Paul Calderone 2019-04-16 11:30:18 -04:00
parent 6ea1684995
commit edba0747a3

View File

@ -763,12 +763,8 @@ class Node(service.MultiService):
# to use "flogtool tail" against a remote server), but for now I # to use "flogtool tail" against a remote server), but for now I
# think we can live without it. # think we can live without it.
self.log_tub = Tub() self.log_tub = Tub()
portnum = iputil.allocate_tcp_port() portnum = iputil.listenOnUnused(self.log_tub)
port = "tcp:%d:interface=127.0.0.1" % portnum self.log("Log Tub location set to 127.0.0.1:%s" % (portnum,))
location = "tcp:127.0.0.1:%d" % portnum
self.log_tub.listenOn(port)
self.log_tub.setLocation(location)
self.log("Log Tub location set to %s" % (location,))
self.log_tub.setServiceParent(self) self.log_tub.setServiceParent(self)
def startService(self): def startService(self):