summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-09-19 17:26:36 -0400
committerMartin Kosek <mkosek@redhat.com>2011-09-23 10:49:59 +0200
commitb8461e8d5661fbae86e0fb9c6dc85554704a4f0a (patch)
treec32bde882d01ac719246441610b0578a9f33e800 /ipapython
parente4f40a98a6e164f0ea8dc6d26d40bcd5de7dd597 (diff)
downloadfreeipa-b8461e8d5661fbae86e0fb9c6dc85554704a4f0a.tar.gz
freeipa-b8461e8d5661fbae86e0fb9c6dc85554704a4f0a.tar.xz
freeipa-b8461e8d5661fbae86e0fb9c6dc85554704a4f0a.zip
Shut down duplicated file handle when HTTP response code is not 200.
httplib purposely keeps the socket open as a file on failed requests. We need to close this file otherwise nss_shutdown() will fail. https://fedorahosted.org/freeipa/ticket/1807
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/nsslib.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py
index c4d8cdcf6..467de1c42 100644
--- a/ipapython/nsslib.py
+++ b/ipapython/nsslib.py
@@ -293,6 +293,17 @@ class NSSHTTPS(httplib.HTTP):
port = None
self._setup(self._connection_class(host, port, strict, dbdir=dbdir))
+ def getreply(self):
+ """
+ Override so we can close duplicated file connection on non-200
+ responses. This was causing nss_shutdown() to fail with a busy
+ error.
+ """
+ (status, reason, msg) = httplib.HTTP.getreply(self)
+ if status != 200:
+ self.file.close()
+ return (status, reason, msg)
+
#------------------------------------------------------------------------------
if __name__ == "__main__":