aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Dymond <max.dymond@metaswitch.com>2017-06-30 12:45:17 +0100
committerDaniel Stenberg <daniel@haxx.se>2017-06-30 14:58:06 +0200
commit0362c778418a7c0594dae5537f91247ca1dae289 (patch)
treec6a6a016416537f2917b9f4ba3984ba6fce251d7
parent9b387034ab5d0d98d1ef4b6c2d0d8cd2185081fb (diff)
test1450: fix up DICT server in torture mode
As per https://github.com/curl/curl/pull/1615, the DICT server is a little spammy in torture mode due to the sockets being torn down unexpectedly. Fix this by adding some error handling to the handling function. Closes #1629
-rwxr-xr-xtests/dictserver.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/tests/dictserver.py b/tests/dictserver.py
index 45cc15505..a41a8a0d6 100755
--- a/tests/dictserver.py
+++ b/tests/dictserver.py
@@ -52,34 +52,37 @@ class DictHandler(socketserver.BaseRequestHandler):
"""
Simple function which responds to all queries with a 552.
"""
+ try:
+ # First, send a response to allow the server to continue.
+ rsp = "220 dictserver <xnooptions> <msgid@msgid>\n"
+ self.request.sendall(rsp.encode("utf-8"))
- # First, send a response to allow the server to continue.
- rsp = "220 dictserver <xnooptions> <msgid@msgid>\n"
- self.request.sendall(rsp.encode("utf-8"))
+ # Receive the request.
+ data = self.request.recv(1024).strip()
+ log.debug("[DICT] Incoming data: %r", data)
- # Receive the request.
- data = self.request.recv(1024).strip()
- log.debug("[DICT] Incoming data: %r", data)
+ if VERIFIED_REQ in data:
+ log.debug("[DICT] Received verification request from test "
+ "framework")
+ response_data = VERIFIED_RSP.format(pid=os.getpid())
+ else:
+ log.debug("[DICT] Received normal request")
+ response_data = "No matches"
- if VERIFIED_REQ in data:
- log.debug("[DICT] Received verification request from test "
- "framework")
- response_data = VERIFIED_RSP.format(pid=os.getpid())
- else:
- log.debug("[DICT] Received normal request")
- response_data = "No matches"
+ # Send back a failure to find.
+ response = "552 {0}\n".format(response_data)
+ log.debug("[DICT] Responding with %r", response)
+ self.request.sendall(response.encode("utf-8"))
- # Send back a failure to find.
- response = "552 {0}\n".format(response_data)
- log.debug("[DICT] Responding with %r", response)
- self.request.sendall(response.encode("utf-8"))
+ except IOError:
+ log.exception("[DICT] IOError hit during request")
def get_options():
parser = argparse.ArgumentParser()
parser.add_argument("--port", action="store", default=9016,
- type=int, help="port to listen on")
+ type=int, help="port to listen on")
parser.add_argument("--verbose", action="store", type=int, default=0,
help="verbose output")
parser.add_argument("--pidfile", action="store",