aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-15 22:54:43 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-16 10:04:08 +0100
commit7bc79fdf60519231da7c0c7b5b6143ce090ed830 (patch)
treefb883789484d64e66e511d402d6fc87f8bd94205
parent6e6865e6371dbd31a136eae64cc5b1fa5f5bee33 (diff)
downloadbitbake-7bc79fdf60519231da7c0c7b5b6143ce090ed830.tar.gz
hashserv: Ensure we don't accumulate sockets in TIME_WAIT state
This can cause a huge backlog of closing sockets on the server and in our case we don't really want/need the protection TCP is trying to give us so work around it. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/hashserv/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/hashserv/__init__.py b/lib/hashserv/__init__.py
index 55966e748..eb03c3221 100644
--- a/lib/hashserv/__init__.py
+++ b/lib/hashserv/__init__.py
@@ -14,6 +14,8 @@ import socketserver
import queue
import threading
import signal
+import socket
+import struct
from datetime import datetime
logger = logging.getLogger('hashserv')
@@ -157,6 +159,10 @@ class ThreadedHTTPServer(HTTPServer):
self.server_close()
os._exit(0)
+ def server_bind(self):
+ HTTPServer.server_bind(self)
+ self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0))
+
def process_request_thread(self):
while not self.quit:
try: