Skip to content

Commit

Permalink
[Test] Fix sockets reusing
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed May 31, 2019
1 parent ff83de0 commit c283637
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions test/functional/util/dummy_http.py
Expand Up @@ -30,7 +30,7 @@ def do_HEAD(self):

def do_GET(self):
response = "hello world"

"""Respond to a GET request."""
if self.path == "/empty":
self.finish()
Expand All @@ -55,7 +55,7 @@ def do_GET(self):
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))


Expand All @@ -73,7 +73,7 @@ def do_POST(self):
self.send_response(403)
else:
self.send_response(200)

if self.path == "/content-length":
self.send_header("Content-Length", str(len(response)))

Expand All @@ -85,10 +85,10 @@ def do_POST(self):
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:
Expand Down
4 changes: 2 additions & 2 deletions test/functional/util/dummy_killer.py
Expand Up @@ -5,7 +5,7 @@
def setup_killer(server, method = None):
def default_method():
server.server_close()

if method is None:
method = default_method

Expand All @@ -14,7 +14,7 @@ def alarm_handler(signum, frame):

signal.signal(signal.SIGALRM, alarm_handler)
signal.signal(signal.SIGTERM, alarm_handler)
signal.alarm(10)
signal.alarm(30)


def write_pid(path):
Expand Down
1 change: 1 addition & 0 deletions test/functional/util/dummy_udp.py
Expand Up @@ -15,6 +15,7 @@
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)

Expand Down

0 comments on commit c283637

Please sign in to comment.