diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-08-28 16:40:43 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-08-28 16:40:44 -0400 |
commit | ee3c5b0aa41e82b71b3df93f07dd92392e914264 (patch) | |
tree | a0a14c0a6dfff5853780544c9248da2af0ad6b54 /src/lib | |
parent | 867a3efa905945342a83312c6b7e2cb8b09ee51e (diff) | |
download | bcfg2-ee3c5b0aa41e82b71b3df93f07dd92392e914264.tar.gz bcfg2-ee3c5b0aa41e82b71b3df93f07dd92392e914264.tar.bz2 bcfg2-ee3c5b0aa41e82b71b3df93f07dd92392e914264.zip |
SSLServer: Poll for POST data correctly
This updates the do_POST() code to cleave more closely to the code in
SimpleXMLRPCHandler.do_POST (plus SSL magic, of course). In doing so,
it eliminates a select() call whose timeouts were not handled
properly, and which thus left stray idle processes around after
incomplete XML-RPC calls.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Bcfg2/SSLServer.py | 21 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/BuiltinCore.py | 1 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/lib/Bcfg2/SSLServer.py b/src/lib/Bcfg2/SSLServer.py index 316c2f86c..b4fa4cf8d 100644 --- a/src/lib/Bcfg2/SSLServer.py +++ b/src/lib/Bcfg2/SSLServer.py @@ -5,7 +5,6 @@ better. """ import os import sys import socket -import select import signal import logging import ssl @@ -183,7 +182,6 @@ class XMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler): Adds support for HTTP authentication. """ - logger = logging.getLogger("Bcfg2.SSLServer.XMLRPCRequestHandler") def authenticate(self): @@ -228,22 +226,24 @@ class XMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler): return False return True - ### need to override do_POST here def do_POST(self): try: max_chunk_size = 10 * 1024 * 1024 size_remaining = int(self.headers["content-length"]) L = [] while size_remaining: - try: - select.select([self.rfile.fileno()], [], [], 3) - except select.error: - print("got select timeout") - raise chunk_size = min(size_remaining, max_chunk_size) - L.append(self.rfile.read(chunk_size).decode('utf-8')) + chunk = self.rfile.read(chunk_size) + if not chunk: + break + L.append(chunk) size_remaining -= len(L[-1]) data = ''.join(L) + + data = self.decode_request_content(data) + if data is None: + return # response has been sent + response = self.server._marshaled_dispatch(self.client_address, data) if sys.hexversion >= 0x03000000: @@ -251,6 +251,7 @@ class XMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler): except: # pylint: disable=W0702 try: self.send_response(500) + self.send_header("Content-length", "0") self.end_headers() except: (etype, msg) = sys.exc_info()[:2] @@ -431,8 +432,6 @@ class XMLRPCServer(SocketServer.ThreadingMixIn, SSLServer, self.handle_request() except socket.timeout: pass - except select.error: - pass except: self.logger.error("Got unexpected error in handle_request", exc_info=1) diff --git a/src/lib/Bcfg2/Server/BuiltinCore.py b/src/lib/Bcfg2/Server/BuiltinCore.py index 2dd83289d..93da767c7 100644 --- a/src/lib/Bcfg2/Server/BuiltinCore.py +++ b/src/lib/Bcfg2/Server/BuiltinCore.py @@ -110,7 +110,6 @@ class Core(BaseCore): keyfile=self.setup['key'], certfile=self.setup['cert'], register=False, - timeout=1, ca=self.setup['ca'], protocol=self.setup['protocol']) except: # pylint: disable=W0702 |