|
|
ac7d03 |
From bdaf584ef5ebcae08e86142ceb80ebe56ac11fa3 Mon Sep 17 00:00:00 2001
|
|
|
ac7d03 |
From: Christian Heimes <cheimes@redhat.com>
|
|
|
ac7d03 |
Date: Mon, 20 Mar 2017 08:47:51 +0100
|
|
|
ac7d03 |
Subject: [PATCH] Add debug logging for keep-alive
|
|
|
ac7d03 |
|
|
|
ac7d03 |
Signed-off-by: Christian Heimes <cheimes@redhat.com>
|
|
|
ac7d03 |
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
|
|
|
ac7d03 |
---
|
|
|
ac7d03 |
ipalib/rpc.py | 21 ++++++++++++++++++++-
|
|
|
ac7d03 |
1 file changed, 20 insertions(+), 1 deletion(-)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
diff --git a/ipalib/rpc.py b/ipalib/rpc.py
|
|
|
ac7d03 |
index 8d587180a65bd06b644c6df23ac9fb26eb7e97dd..38321d17cf2c9529738aa45cc44bbd38b08b032b 100644
|
|
|
ac7d03 |
--- a/ipalib/rpc.py
|
|
|
ac7d03 |
+++ b/ipalib/rpc.py
|
|
|
ac7d03 |
@@ -79,6 +79,13 @@ except ImportError:
|
|
|
ac7d03 |
from xmlrpc.client import (Binary, Fault, DateTime, dumps, loads, ServerProxy,
|
|
|
ac7d03 |
Transport, ProtocolError, MININT, MAXINT)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
+# pylint: disable=import-error
|
|
|
ac7d03 |
+if six.PY3:
|
|
|
ac7d03 |
+ from http.client import RemoteDisconnected
|
|
|
ac7d03 |
+else:
|
|
|
ac7d03 |
+ from httplib import BadStatusLine as RemoteDisconnected
|
|
|
ac7d03 |
+# pylint: enable=import-error
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
|
|
|
ac7d03 |
if six.PY3:
|
|
|
ac7d03 |
unicode = str
|
|
|
ac7d03 |
@@ -531,6 +538,7 @@ class SSLTransport(LanguageAwareTransport):
|
|
|
ac7d03 |
host, self._extra_headers, _x509 = self.get_host_info(host)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
if self._connection and host == self._connection[0]:
|
|
|
ac7d03 |
+ root_logger.debug("HTTP connection keep-alive (%s)", host)
|
|
|
ac7d03 |
return self._connection[1]
|
|
|
ac7d03 |
|
|
|
ac7d03 |
conn = create_https_connection(
|
|
|
ac7d03 |
@@ -540,6 +548,7 @@ class SSLTransport(LanguageAwareTransport):
|
|
|
ac7d03 |
tls_version_max=api.env.tls_version_max)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
conn.connect()
|
|
|
ac7d03 |
+ root_logger.debug("New HTTP connection (%s)", host)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
self._connection = host, conn
|
|
|
ac7d03 |
return self._connection[1]
|
|
|
ac7d03 |
@@ -686,8 +695,18 @@ class KerbTransport(SSLTransport):
|
|
|
ac7d03 |
return self.parse_response(response)
|
|
|
ac7d03 |
except gssapi.exceptions.GSSError as e:
|
|
|
ac7d03 |
self._handle_exception(e)
|
|
|
ac7d03 |
- except BaseException:
|
|
|
ac7d03 |
+ except RemoteDisconnected:
|
|
|
ac7d03 |
+ # keep-alive connection was terminated by remote peer, close
|
|
|
ac7d03 |
+ # connection and let transport handle reconnect for us.
|
|
|
ac7d03 |
+ self.close()
|
|
|
ac7d03 |
+ root_logger.debug("HTTP server has closed connection (%s)", host)
|
|
|
ac7d03 |
+ raise
|
|
|
ac7d03 |
+ except BaseException as e:
|
|
|
ac7d03 |
+ # Unexpected exception may leave connections in a bad state.
|
|
|
ac7d03 |
self.close()
|
|
|
ac7d03 |
+ root_logger.debug("HTTP connection destroyed (%s)",
|
|
|
ac7d03 |
+ host, exc_info=True)
|
|
|
ac7d03 |
+ raise
|
|
|
ac7d03 |
|
|
|
ac7d03 |
if six.PY3:
|
|
|
ac7d03 |
def __send_request(self, connection, host, handler, request_body, debug):
|
|
|
ac7d03 |
--
|
|
|
ac7d03 |
2.12.1
|
|
|
ac7d03 |
|