From 05c0480c427278eafed77eeab4d7d4088fa4b3e5 Mon Sep 17 00:00:00 2001 From: Peter Hatina Date: Fri, 6 Dec 2013 09:02:25 +0100 Subject: [PATCH 1/2] fix blocking when receiving indication --- cli/lmi/shell/LMIIndicationListener.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/lmi/shell/LMIIndicationListener.py b/cli/lmi/shell/LMIIndicationListener.py index cc48b9b..4f70e77 100644 --- a/cli/lmi/shell/LMIIndicationListener.py +++ b/cli/lmi/shell/LMIIndicationListener.py @@ -62,7 +62,12 @@ class LMIIndicationHandler(ThreadingMixIn, BaseHTTPRequestHandler): where the ``indication_name`` is a string, which properly defines the indication. """ - msg = self.rfile.read() + # If HTTP/1.1 used, try to get a message body length. If Content-Length header is + # not present, set length to -1; rfile.read() will block, until the connection is + # closed. Knowing the exact content length makes the routine to finish early, even + # if the TCP connection is not closed. + length = int(self.headers.get("Content-Length", "-1")) + msg = self.rfile.read(length) tt = pywbem.parse_cim(pywbem.xml_to_tupletree(msg)) message = tt[2] export_methods = {} -- Peter Hatina ENG Server Experience, System Management Red Hat Czech, Brno