diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-07-24 22:11:08 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-07-24 22:11:08 +0000 |
commit | 8d7411d78b87020a7c5765dc294118f24449db0c (patch) | |
tree | 2dd2591e405472b7352ed4c20b3a6da3aa05c5d0 | |
parent | 49a120726690bb434d57e9c39fcf0aad3af8ed9e (diff) | |
parent | 5d90740f33d80db5559becc0cc619d965a4bb292 (diff) | |
download | python-glanceclient-8d7411d78b87020a7c5765dc294118f24449db0c.tar.gz |
Merge "HTTPS response issues"
-rw-r--r-- | glanceclient/common/http.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index d69e4d9..5a888dd 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -288,6 +288,11 @@ class OpenSSLConnectionDelegator(object): return getattr(self.connection, name) def makefile(self, *args, **kwargs): + # Making sure socket is closed when this file is closed + # since we now avoid closing socket on connection close + # see new close method under VerifiedHTTPSConnection + kwargs['close'] = True + return socket._fileobject(self.connection, *args, **kwargs) @@ -413,10 +418,21 @@ class VerifiedHTTPSConnection(HTTPSConnection): if self.timeout is not None: # '0' microseconds sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, - struct.pack('LL', self.timeout, 0)) + struct.pack('fL', self.timeout, 0)) self.sock = OpenSSLConnectionDelegator(self.context, sock) self.sock.connect((self.host, self.port)) + def close(self): + if self.sock: + # Removing reference to socket but don't close it yet. + # Response close will close both socket and associated + # file. Closing socket too soon will cause response + # reads to fail with socket IO error 'Bad file descriptor'. + self.sock = None + + # Calling close on HTTPConnection to continue doing that cleanup. + HTTPSConnection.close(self) + class ResponseBodyIterator(object): """A class that acts as an iterator over an HTTP response.""" |