commit c283637: [Test] Fix sockets reusing
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri May 31 14:21:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-05-31 15:19:00 +0100
URL: https://github.com/rspamd/rspamd/commit/c28363722ff0acbd650d188cecee1730301d7c10
[Test] Fix sockets reusing
---
test/functional/util/dummy_http.py | 10 +++++-----
test/functional/util/dummy_killer.py | 4 ++--
test/functional/util/dummy_udp.py | 1 +
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/test/functional/util/dummy_http.py b/test/functional/util/dummy_http.py
index dc4cee354..614fced29 100755
--- a/test/functional/util/dummy_http.py
+++ b/test/functional/util/dummy_http.py
@@ -30,7 +30,7 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
response = "hello world"
-
+
"""Respond to a GET request."""
if self.path == "/empty":
self.finish()
@@ -55,7 +55,7 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
conntype = self.headers.get('Connection', "").lower()
if conntype != 'keep-alive':
self.close_connection = True
-
+
self.log_message("ka:'%s', pv:%s[%s]" % (str(conntype == 'keep-alive'), str(self.protocol_version >= "HTTP/1.1"), self.protocol_version))
@@ -73,7 +73,7 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.send_response(403)
else:
self.send_response(200)
-
+
if self.path == "/content-length":
self.send_header("Content-Length", str(len(response)))
@@ -85,10 +85,10 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
def __init__(self):
- BaseHTTPServer.HTTPServer.__init__(self, (HOST_NAME, PORT), MyHandler)
self.allow_reuse_address = True
self.timeout = 1
-
+ BaseHTTPServer.HTTPServer.__init__(self, (HOST_NAME, PORT), MyHandler)
+
def run(self):
dummy_killer.write_pid(PID)
try:
diff --git a/test/functional/util/dummy_killer.py b/test/functional/util/dummy_killer.py
index 723e6ef4a..85b3d01ba 100644
--- a/test/functional/util/dummy_killer.py
+++ b/test/functional/util/dummy_killer.py
@@ -5,7 +5,7 @@ import atexit
def setup_killer(server, method = None):
def default_method():
server.server_close()
-
+
if method is None:
method = default_method
@@ -14,7 +14,7 @@ def setup_killer(server, method = None):
signal.signal(signal.SIGALRM, alarm_handler)
signal.signal(signal.SIGTERM, alarm_handler)
- signal.alarm(10)
+ signal.alarm(30)
def write_pid(path):
diff --git a/test/functional/util/dummy_udp.py b/test/functional/util/dummy_udp.py
index 4d904e3b1..02ee6dce8 100755
--- a/test/functional/util/dummy_udp.py
+++ b/test/functional/util/dummy_udp.py
@@ -15,6 +15,7 @@ if __name__ == "__main__":
port = 5005
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((UDP_IP, port))
dummy_killer.write_pid(PID)
More information about the Commits
mailing list