Nir Soffer has uploaded a new change for review.
Change subject: xmlrpc: Fix connection reset on Python 2.6
......................................................................
xmlrpc: Fix connection reset on Python 2.6
When request is aborted before the reading the entire request, closing the
socket cause the other side to receive connection reset, and loose the response
data. Python 2.7 introduced the shutdown_request method, fixing this issue.
This patch check if SimpleXMLRPCServer has the shutdown_request method, and if
not, do a clean request shutdwon in close_request.
Change-Id: Id77a32bb0d4fff13ee680eade52a2f60e4e808b5
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/utils.py
1 file changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/24026/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index 9429308..eeea5d4 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -158,6 +158,23 @@
logRequests, allow_none, encoding,
bind_and_activate)
+ # Fix for connection reset issue when running on Python 2.6. This happens
+ # when request is aborted before the reading the entire request. Closing
+ # the socket cause the other side to receive connection reset, and loose
+ # the response data. Python 2.7 introduced the shutdown_request method,
+ # fixing this issue. If we run on a version without this method, we will do
+ # a clean shutdown in close_request instead.
+ if not hasattr(SimpleXMLRPCServer, 'shutdown_request'):
+ def close_request(self, request):
+ # From Python 2.7 SocketServer.TCPServer.shutdown_request
+ try:
+ # Explicitly shutdown. socket.close() merely releases the
+ # socket and waits for GC to perform the actual close.
+ request.shutdown(socket.SHUT_WR)
+ except socket.error:
+ pass # Some platforms may raise ENOTCONN here
+ SimpleXMLRPCServer.close_request(self, request)
+
#Threaded version of SimpleXMLRPCServer
class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn,
--
To view, visit
http://gerrit.ovirt.org/24026
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id77a32bb0d4fff13ee680eade52a2f60e4e808b5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>