From 7057a59c56d539d7bcfb3c45697fff7a5dbda17e Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Thu, 20 Aug 2015 14:54:47 -0700 Subject: [PATCH] Handle failed async requests. --- src/XrdFileCache/XrdFileCacheFile.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/XrdFileCache/XrdFileCacheFile.cc b/src/XrdFileCache/XrdFileCacheFile.cc index bad57321fef..762406454da 100644 --- a/src/XrdFileCache/XrdFileCacheFile.cc +++ b/src/XrdFileCache/XrdFileCacheFile.cc @@ -463,6 +463,7 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize) // passing the req to client is actually better. // unlock + bool preProcOK = true; m_downloadCond.Lock(); // XXX Check for blocks to free? Later ... @@ -504,7 +505,9 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize) { clLog()->Dump(XrdCl::AppMsg, "File::Read() u=%p inc_ref_count new %d %s", (void*)iUserBuff, block_idx, lPath()); Block *b = RequestBlock(block_idx, false); - assert(b); + // assert(b); + preProcOK = false; + break; inc_ref_count(b); blks_to_process.push_back(b); m_stats.m_BytesRam++; @@ -516,11 +519,23 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize) blks_direct.push_back(block_idx); m_stats.m_BytesMissed++; } - } + } + } + m_downloadCond.UnLock(); + + + + if (!preProcOK) { + for (BlockList_i i = blks_to_process.begin(); i!= blks_to_process.end(); ++i ) + dec_ref_count(*i); + return -1; // AMT ??? + } + + long long bytes_read = 0; // First, send out any direct requests. @@ -533,6 +548,13 @@ int File::Read(char* iUserBuff, long long iUserOff, int iUserSize) direct_handler = new DirectResponseHandler(blks_direct.size()); direct_size = RequestBlocksDirect(direct_handler, blks_direct, iUserBuff, iUserOff, iUserSize); + // failed to send direct client request + if (direct_size < 0) { + for (BlockList_i i = blks_to_process.begin(); i!= blks_to_process.end(); ++i ) + dec_ref_count(*i); + delete direct_handler; + return -1; // AMT ??? + } clLog()->Dump(XrdCl::AppMsg, "File::Read() direct read %d. %s", direct_size, lPath()); }