summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2018-11-27 11:24:38 +1100
committerChris Johns <chrisj@rtems.org>2018-11-27 11:24:38 +1100
commitbf5fdab115d8dc583548f6c270353fdb6d01c3a0 (patch)
tree20a46c8dc48d036dae5ee68ed735c6632d796f38
parenttester: Fix the handling of the version and tools recs when running parallel ... (diff)
downloadrtems-tools-bf5fdab115d8dc583548f6c270353fdb6d01c3a0.tar.bz2
tester/tftpd: Set the socket option to reuse.
-rw-r--r--tester/rt/tftpy/TftpServer.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tester/rt/tftpy/TftpServer.py b/tester/rt/tftpy/TftpServer.py
index 95ca70e..8dc6d78 100644
--- a/tester/rt/tftpy/TftpServer.py
+++ b/tester/rt/tftpy/TftpServer.py
@@ -76,6 +76,13 @@ class TftpServer(TftpSession):
else:
raise TftpException("The tftproot does not exist.")
+ def __del__(self):
+ if self.sock is not None:
+ try:
+ self.sock.close()
+ except:
+ pass
+
def listen(self, listenip="", listenport=DEF_TFTP_PORT,
timeout=SOCK_TIMEOUT):
"""Start a server listening on the supplied interface and port. This
@@ -90,6 +97,7 @@ class TftpServer(TftpSession):
try:
# FIXME - sockets should be non-blocking
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.bind((listenip, listenport))
_, self.listenport = self.sock.getsockname()
except socket.error as err: