Blob Blame History Raw
From 2ab600c98abe37f3550b4ff709d92efd00c6792d Mon Sep 17 00:00:00 2001
From: Michal Simon <michal.simon@cern.ch>
Date: Fri, 9 Nov 2018 12:36:23 +0100
Subject: [PATCH] [XrdCl] Handle properly seerver disconnect.

---
 src/XrdCl/XrdClXRootDTransport.cc | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/XrdCl/XrdClXRootDTransport.cc b/src/XrdCl/XrdClXRootDTransport.cc
index 0ff3e5d1..75002dc6 100644
--- a/src/XrdCl/XrdClXRootDTransport.cc
+++ b/src/XrdCl/XrdClXRootDTransport.cc
@@ -227,7 +227,13 @@ namespace XrdCl
       while( leftToBeRead )
       {
         int status = ::read( socket, message->GetBufferAtCursor(), leftToBeRead );
-        if( status <= 0 )
+
+        // if the server shut down the socket declare a socket error (it
+        // will trigger a re-connect)
+        if( status == 0 )
+          return Status( stError, errSocketError, errno );
+
+        if( status < 0 )
           return ClassifyErrno( errno );
 
         leftToBeRead -= status;
@@ -263,7 +269,13 @@ namespace XrdCl
     while( leftToBeRead )
     {
       int status = ::read( socket, message->GetBufferAtCursor(), leftToBeRead );
-      if( status <= 0 )
+
+      // if the server shut down the socket declare a socket error (it
+      // will trigger a re-connect)
+      if( status == 0 )
+        return Status( stError, errSocketError, errno );
+
+      if( status < 0 )
         return ClassifyErrno( errno );
 
       leftToBeRead -= status;
-- 
2.19.1