From 0ce5a495f087cec29cf463e42d7ff87834ad0edb Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 27 Feb 2023 12:35:19 +0100 Subject: [PATCH] do not reuse address on Windows socketserver.ThreadingTCPServer.allow_reuse_address must be False on Windows systems, else several servers might be started on the same port, and unspecified behaviour will happen Fixes: #4695 Change-Id: Ic9f193e23854f9cd3413ab6e664ca8029a7c9c76 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30523 Tested-by: Jenkins Automated Tests Reviewed-by: Georg Brandl Reviewed-by: Markus Zolliker --- frappy/protocol/interface/tcp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frappy/protocol/interface/tcp.py b/frappy/protocol/interface/tcp.py index e57e621..8a8b3f3 100644 --- a/frappy/protocol/interface/tcp.py +++ b/frappy/protocol/interface/tcp.py @@ -27,6 +27,7 @@ import sys import threading import time import errno +import os from frappy.datatypes import BoolType, StringType from frappy.errors import SECoPError @@ -169,7 +170,9 @@ class TCPRequestHandler(socketserver.BaseRequestHandler): class TCPServer(socketserver.ThreadingTCPServer): daemon_threads = True - allow_reuse_address = True + # on windows, 'reuse_address' means that several servers might listen on + # the same port, on the other hand, a port is not blocked after closing + allow_reuse_address = os.name != 'nt' # False on Windows systems # for cfg-editor configurables = {