From a5e90f2aa7eaf12b06fed670ee7e7b93309c7b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Thu, 6 Feb 2020 13:36:32 +0100 Subject: [PATCH] Fix the "pipelined" system test on OpenBSD On OpenBSD, the bin/tests/system/pipelined/ans5/ans.py script does not shut down when it is sent the SIGTERM signal. What seems to be happening is that starting the UDP listening thread somehow makes the accept() calls in the script's main thread uninterruptible and thus the SIGTERM signal sent to the main thread does not get processed until a TCP connection is established with the script's TCP socket. Work around the issue by setting a timeout for operations performed on the script's TCP socket, so that each accept() call in the main thread's infinite loop returns after at most 1 second, allowing termination signals sent to the script to be processed. --- bin/tests/system/pipelined/ans5/ans.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/tests/system/pipelined/ans5/ans.py b/bin/tests/system/pipelined/ans5/ans.py index 1ebf328d6d..ffb1d89db8 100644 --- a/bin/tests/system/pipelined/ans5/ans.py +++ b/bin/tests/system/pipelined/ans5/ans.py @@ -182,13 +182,17 @@ def main(): sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((listenip, port)) sock.listen(1) + sock.settimeout(1) while True: - (clientsock, _) = sock.accept() - log('Accepted connection from %s' % clientsock) - thread = TCPDelayer(clientsock, serverip, port) - thread.start() - THREADS.append(thread) + try: + (clientsock, _) = sock.accept() + log('Accepted connection from %s' % clientsock) + thread = TCPDelayer(clientsock, serverip, port) + thread.start() + THREADS.append(thread) + except socket.timeout: + pass if __name__ == '__main__': main()