diff options
author | Christian Heimes <cheimes@redhat.com> | 2017-03-20 08:47:51 +0100 |
---|---|---|
committer | Tomas Krizek <tkrizek@redhat.com> | 2017-03-20 19:24:28 +0100 |
commit | b2bdd2e1a912573ae4a3e8e5f40831a800d972f7 (patch) | |
tree | d769ed2f11c0835277094c0c54a16c4ec68e512b | |
parent | 7beb6d1cad7e2200208cb14be6c823a89abf0dc3 (diff) | |
download | freeipa-b2bdd2e1a912573ae4a3e8e5f40831a800d972f7.tar.gz freeipa-b2bdd2e1a912573ae4a3e8e5f40831a800d972f7.tar.xz freeipa-b2bdd2e1a912573ae4a3e8e5f40831a800d972f7.zip |
Add debug logging for keep-alive
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
-rw-r--r-- | ipalib/rpc.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ipalib/rpc.py b/ipalib/rpc.py index 106cabe66..303b22a8a 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -79,6 +79,13 @@ except ImportError: from xmlrpc.client import (Binary, Fault, DateTime, dumps, loads, ServerProxy, Transport, ProtocolError, MININT, MAXINT) +# pylint: disable=import-error +if six.PY3: + from http.client import RemoteDisconnected +else: + from httplib import BadStatusLine as RemoteDisconnected +# pylint: enable=import-error + if six.PY3: unicode = str @@ -531,6 +538,7 @@ class SSLTransport(LanguageAwareTransport): host, self._extra_headers, _x509 = self.get_host_info(host) if self._connection and host == self._connection[0]: + root_logger.debug("HTTP connection keep-alive (%s)", host) return self._connection[1] conn = create_https_connection( @@ -540,6 +548,7 @@ class SSLTransport(LanguageAwareTransport): tls_version_max=api.env.tls_version_max) conn.connect() + root_logger.debug("New HTTP connection (%s)", host) self._connection = host, conn return self._connection[1] @@ -686,8 +695,18 @@ class KerbTransport(SSLTransport): return self.parse_response(response) except gssapi.exceptions.GSSError as e: self._handle_exception(e) - except BaseException: + except RemoteDisconnected: + # keep-alive connection was terminated by remote peer, close + # connection and let transport handle reconnect for us. + self.close() + root_logger.debug("HTTP server has closed connection (%s)", host) + raise + except BaseException as e: + # Unexpected exception may leave connections in a bad state. self.close() + root_logger.debug("HTTP connection destroyed (%s)", + host, exc_info=True) + raise if six.PY3: def __send_request(self, connection, host, handler, request_body, debug): |