From 4109322f1c50d9aabe0f8199865fe552fb3ec843 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Sat, 29 May 2021 14:01:11 -0700 Subject: [PATCH] Close fingergw connection handler on input termination When a connection to the fingergw is terminated with no input, the recv() method returns the empty string after poll returns an event with the input flag set. Handle that case by raising a BrokenPipeError which is already handled by the calling code as a remote hang-up. This has a noticeable impact on the test latency. Change-Id: Ia56c94bc1e764b2f0f8ce3d6994689a3e2f7daff --- zuul/lib/streamer_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zuul/lib/streamer_utils.py b/zuul/lib/streamer_utils.py index 9459462974..87c16fa695 100644 --- a/zuul/lib/streamer_utils.py +++ b/zuul/lib/streamer_utils.py @@ -50,7 +50,11 @@ class BaseFingerRequestHandler(socketserver.BaseRequestHandler): raise Exception("Timeout while waiting for input") for fd, event in poll.poll(timeout): if event & select.POLLIN: - buffer += self.request.recv(self.MAX_REQUEST_LEN) + x = self.request.recv(self.MAX_REQUEST_LEN) + if not x: + # This will cause the caller to quietly shut down + raise BrokenPipeError + buffer += x else: raise Exception("Received error event") if len(buffer) >= self.MAX_REQUEST_LEN: