Skip to content

Commit

Permalink
Use result as error code in response handlers, not errno.
Browse files Browse the repository at this point in the history
  • Loading branch information
osschar committed Aug 18, 2016
1 parent 87ceabb commit da8d640
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
7 changes: 3 additions & 4 deletions src/XrdFileCache/XrdFileCacheFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,7 @@ void File::ProcessBlockResponse(Block* b, int res)
TRACEF(Error, "File::ProcessBlockResponse block " << b << " " << (int)(b->m_offset/BufferSize()) << " error=" << res);
// XrdPosixMap::Result(*status);
// AMT could notfiy global cache we dont need RAM for that block
b->set_error_and_free(errno);
errno = 0;
b->set_error_and_free(res);

// ??? AMT how long to keep
inc_ref_count(b);
Expand Down Expand Up @@ -983,7 +982,7 @@ XrdOucTrace* File::GetTrace()
}

//==============================================================================
//======================= RESPONSE HANDLER ===============================
//======================= RESPONSE HANDLERS ==============================
//==============================================================================

void BlockResponseHandler::Done(int res)
Expand All @@ -1003,7 +1002,7 @@ void DirectResponseHandler::Done(int res)

if (res < 0)
{
m_errno = errno;
m_errno = res;
}

if (m_to_wait == 0)
Expand Down
25 changes: 12 additions & 13 deletions src/XrdFileCache/XrdFileCacheFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ namespace XrdFileCache

namespace XrdFileCache
{
class RefCounted
{
int m_refcnt;

RefCounted() : m_refcnt(0) {}
};

class File;

class Block
Expand Down Expand Up @@ -91,7 +84,8 @@ namespace XrdFileCache
void set_error_and_free(int err)
{
m_errno = err;
m_buff.resize(0);
std::vector<char> x;
m_buff.swap(x);
}
};

Expand Down Expand Up @@ -141,7 +135,6 @@ namespace XrdFileCache
int m_prefetchReadCnt;
int m_prefetchHitCnt;
float m_prefetchScore; //cached
int m_prefetchCurrentCnt;

static const char *m_traceID;

Expand Down Expand Up @@ -225,10 +218,16 @@ namespace XrdFileCache
char* req_buf, long long req_off, long long req_size);

// VRead
bool VReadValidate (const XrdOucIOVec *readV, int n);
bool VReadPreProcess(const XrdOucIOVec *readV, int n, ReadVBlockListRAM& blks_to_process, ReadVBlockListDisk& blks_on_disk, std::vector<XrdOucIOVec>& chunkVec);
int VReadFromDisk(const XrdOucIOVec *readV, int n, ReadVBlockListDisk& blks_on_disk);
int VReadProcessBlocks(const XrdOucIOVec *readV, int n, std::vector<ReadVChunkListRAM>& blks_to_process, std::vector<ReadVChunkListRAM>& blks_rocessed);
bool VReadValidate (const XrdOucIOVec *readV, int n);
bool VReadPreProcess (const XrdOucIOVec *readV, int n,
ReadVBlockListRAM& blks_to_process,
ReadVBlockListDisk& blks_on_disk,
std::vector<XrdOucIOVec>& chunkVec);
int VReadFromDisk (const XrdOucIOVec *readV, int n,
ReadVBlockListDisk& blks_on_disk);
int VReadProcessBlocks(const XrdOucIOVec *readV, int n,
std::vector<ReadVChunkListRAM>& blks_to_process,
std::vector<ReadVChunkListRAM>& blks_rocessed);

long long BufferSize();
void AppendIOStatToFileInfo();
Expand Down
7 changes: 6 additions & 1 deletion src/XrdFileCache/XrdFileCacheVRead.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ int File::ReadV(const XrdOucIOVec *readV, int n)
std::vector<XrdOucIOVec> chunkVec;
DirectResponseHandler *direct_handler = 0;

// XXXX The following call never fails (other than with out of mem exception).
// XXXX This should be implemented in PrepareBlockRequest().
if ( ! VReadPreProcess(readV, n, blocks_to_process, blocks_on_disk, chunkVec))
{
bytesRead = -1;
errno = ENOMEM;
}

// issue a client read

Expand Down Expand Up @@ -324,7 +329,7 @@ int File::VReadProcessBlocks(const XrdOucIOVec *readV, int n,
if (bi->block->is_finished())
{
finished.push_back(ReadVChunkListRAM(bi->block, bi->arr));
// std::vector<ReadVChunkListRAM>::iterator bj = bi++;
// Here we rely on the fact that std::vector does not reallocate on erase!
blocks_to_process.erase(bi);
}
else
Expand Down

0 comments on commit da8d640

Please sign in to comment.