Skip to content

Commit

Permalink
More indentation corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuerstchen committed Aug 25, 2022
1 parent a1e7f27 commit 92bd329
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 80 deletions.
2 changes: 0 additions & 2 deletions src/XrdCl/XrdClOperations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,6 @@ namespace XrdCl
//------------------------------------------------------------------------
uint16_t timeout;
};


}

#endif // __XRD_CL_OPERATIONS_HH__
1 change: 1 addition & 0 deletions src/XrdCl/XrdClZipArchive.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace XrdCl

template<typename RSP>
friend XRootDStatus ReadFromImpl( ZipArchive&, const std::string&, uint64_t, uint32_t, void*, ResponseHandler*, uint16_t );

public:
//-----------------------------------------------------------------------
//! Constructor
Expand Down
144 changes: 71 additions & 73 deletions src/XrdEc/XrdEcReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,28 @@ namespace XrdEc
}

auto pipehndl = [=]( const XrdCl::XRootDStatus &st )
{ // set the central directories in ZIP archives (if we use metadata files)
auto itr = dataarchs.begin();
for (; itr != dataarchs.end(); ++itr) {
const std::string &url = itr->first;
auto &zipptr = itr->second;
if (zipptr->openstage == XrdCl::ZipArchive::NotParsed)
zipptr->SetCD(metadata[url]);
else if (zipptr->openstage != XrdCl::ZipArchive::Done
&& !metadata.empty())
AddMissing(metadata[url]);
auto itr = zipptr->cdmap.begin();
for (; itr != zipptr->cdmap.end(); ++itr) {
try {
size_t blknb = fntoblk(itr->first);
urlmap.emplace(itr->first, url);
if (blknb > lstblk)
lstblk = blknb;
} catch (std::invalid_argument&) {
log->Dump(XrdCl::XRootDMsg, "EC Reader Open: Invalid file name found");
}
}
}
{ // set the central directories in ZIP archives (if we use metadata files)
auto itr = dataarchs.begin();
for (; itr != dataarchs.end(); ++itr) {
const std::string &url = itr->first;
auto &zipptr = itr->second;
if (zipptr->openstage == XrdCl::ZipArchive::NotParsed)
zipptr->SetCD(metadata[url]);
else if (zipptr->openstage != XrdCl::ZipArchive::Done
&& !metadata.empty())
AddMissing(metadata[url]);
auto itr = zipptr->cdmap.begin();
for (; itr != zipptr->cdmap.end(); ++itr) {
try {
size_t blknb = fntoblk(itr->first);
urlmap.emplace(itr->first, url);
if (blknb > lstblk)
lstblk = blknb;
} catch (std::invalid_argument&) {
log->Error(XrdCl::XRootDMsg, "EC Reader Open: Invalid file name found");
}
}
}
metadata.clear();
// call user handler
if( handler )
Expand Down Expand Up @@ -286,48 +286,46 @@ namespace XrdEc
// create a buffer for the data
buffer.resize( objcfg.chunksize );
// issue the read request
XrdCl::Async(
XrdCl::ReadFrom(*zipptr, fn, 0, rdsize, buffer.data())
>> [zipptr, fn, cb, &buffer, this, url, timeout](
XrdCl::XRootDStatus &st, XrdCl::ChunkInfo &ch)
{
//---------------------------------------------------
// If read failed there's nothing to do, just pass the
// status to user callback
//---------------------------------------------------
if( !st.IsOK() )
{
cb( XrdCl::XRootDStatus(st.status, XrdCl::errNotFound, 0, "Read failed"), 0 );
return;
}
//---------------------------------------------------
// Get the checksum for the read data
//---------------------------------------------------
uint32_t orgcksum = 0;
auto s = zipptr->GetCRC32(fn, orgcksum);
//---------------------------------------------------
// If we cannot extract the checksum assume the data
// are corrupted
//---------------------------------------------------
if( !s.IsOK() )
{
cb( XrdCl::XRootDStatus(s.status, s.code, s.errNo, "Chksum fail"), 0 );
return;
}
//---------------------------------------------------
// Verify data integrity
//---------------------------------------------------
uint32_t cksum = objcfg.digest( 0, ch.buffer, ch.length );
if( orgcksum != cksum )
{
cb( XrdCl::XRootDStatus( XrdCl::stError, XrdCl::errCheckSumError, 0, "Chksum of data and cdfh not equal" ), 0 );
return;
}
// checksums identical, call with positive response
cb(XrdCl::XRootDStatus(), ch.length);
return;
}, timeout);
}
XrdCl::Async( XrdCl::ReadFrom(*zipptr, fn, 0, rdsize, buffer.data()) >>
[zipptr, fn, cb, &buffer, this, url, timeout] (XrdCl::XRootDStatus &st, XrdCl::ChunkInfo &ch)
{
//---------------------------------------------------
// If read failed there's nothing to do, just pass the
// status to user callback
//---------------------------------------------------
if( !st.IsOK() )
{
cb( XrdCl::XRootDStatus(st.status, XrdCl::errNotFound, 0, "Read failed"), 0 );
return;
}
//---------------------------------------------------
// Get the checksum for the read data
//---------------------------------------------------
uint32_t orgcksum = 0;
auto s = zipptr->GetCRC32(fn, orgcksum);
//---------------------------------------------------
// If we cannot extract the checksum assume the data
// are corrupted
//---------------------------------------------------
if( !s.IsOK() )
{
cb( XrdCl::XRootDStatus(s.status, s.code, s.errNo, "Chksum fail"), 0 );
return;
}
//---------------------------------------------------
// Verify data integrity
//---------------------------------------------------
uint32_t cksum = objcfg.digest( 0, ch.buffer, ch.length );
if( orgcksum != cksum )
{
cb( XrdCl::XRootDStatus( XrdCl::stError, XrdCl::errCheckSumError, 0, "Chksum of data and cdfh not equal" ), 0 );
return;
}
// checksums identical, call with positive response
cb(XrdCl::XRootDStatus(), ch.length);
return;
}, timeout);
}

//-----------------------------------------------------------------------
// Read metadata for the object
Expand Down Expand Up @@ -600,15 +598,15 @@ namespace XrdEc
auto itr = urlmap.find( fn );
if( itr == urlmap.end() )
{
log->Dump(XrdCl::XRootDMsg, "EC Vector Read: No mapping of file to host found.");
log->Error(XrdCl::XRootDMsg, "EC Vector Read: No mapping of file to host found.");
break;
}
// get the URL of the ZIP archive with the respective data
const std::string &url = itr->second;
auto itr2 = archiveIndices.find(url);
if(itr2 == archiveIndices.end())
{
log->Dump(XrdCl::XRootDMsg, "EC Vector Read: Couldn't find host for file.");
log->Error(XrdCl::XRootDMsg, "EC Vector Read: Couldn't find host for file.");
break;
}
size_t indexOfArchive = archiveIndices[url];
Expand Down Expand Up @@ -671,7 +669,7 @@ namespace XrdEc

if(!st.IsOK())
{
log->Dump(XrdCl::XRootDMsg, "EC Vector Read of host %d failed entirely.", i);
log->Error(XrdCl::XRootDMsg, "EC Vector Read of host %d failed entirely.", i);
MissingVectorRead(currentBlock, blkid, strpid, timeout);
}
else{
Expand All @@ -683,7 +681,7 @@ namespace XrdEc
//---------------------------------------------------
if( !st.IsOK() )
{
log->Dump(XrdCl::XRootDMsg, "EC Vector Read: Couldn't read CRC32 from CD.");
log->Error(XrdCl::XRootDMsg, "EC Vector Read: Couldn't read CRC32 from CD.");
MissingVectorRead(currentBlock, blkid, strpid, timeout);
continue;
}
Expand All @@ -693,15 +691,15 @@ namespace XrdEc
uint32_t cksum = objcfg.digest( 0, currentBlock->stripes[strpid].data(), currentBlock->stripes[strpid].size() );
if( orgcksum != cksum )
{
log->Dump(XrdCl::XRootDMsg, "EC Vector Read: Wrong checksum for block %d stripe %d.", blkid, strpid);
log->Error(XrdCl::XRootDMsg, "EC Vector Read: Wrong checksum for block %d stripe %d.", blkid, strpid);
MissingVectorRead(currentBlock, blkid, strpid, timeout);
continue;
}
else{
currentBlock->state[strpid] = block_t::Valid;
bool recoverable = currentBlock->error_correction( currentBlock );
if(!recoverable)
log->Dump(XrdCl::XRootDMsg, "EC Vector Read: Couldn't recover block %d.", blkid);
log->Error(XrdCl::XRootDMsg, "EC Vector Read: Couldn't recover block %d.", blkid);
}
}
}
Expand Down Expand Up @@ -736,12 +734,12 @@ namespace XrdEc

// put received data into given buffers
if(blockMap.find(blkid) == blockMap.end() || blockMap[blkid] == nullptr){
log->Dump(XrdCl::XRootDMsg, "EC Vector Read: Missing block %d.", blkid);
log->Error(XrdCl::XRootDMsg, "EC Vector Read: Missing block %d.", blkid);
failed = true;
break;
}
if(blockMap[blkid]->state[strpid] != block_t::Valid){
log->Dump(XrdCl::XRootDMsg, "EC Vector Read: Invalid stripe in block %d stripe %d.", blkid, strpid);
log->Error(XrdCl::XRootDMsg, "EC Vector Read: Invalid stripe in block %d stripe %d.", blkid, strpid);
failed = true;
break;
}
Expand All @@ -755,7 +753,7 @@ namespace XrdEc
if(globalBuffer) globalBuffer = localBuffer;
}
if(handler){
if(failed) log->Dump(XrdCl::XRootDMsg, "EC Vector Read failed (at least in part).");
if(failed) log->Error(XrdCl::XRootDMsg, "EC Vector Read failed (at least in part).");
if(failed) handler->HandleResponse(new XrdCl::XRootDStatus(XrdCl::stError, "Couldn't read all segments"), nullptr);
else handler->HandleResponse(new XrdCl::XRootDStatus(), nullptr);
}
Expand Down
1 change: 1 addition & 0 deletions src/XrdZip/XrdZipEOCD.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace XrdZip
if(maxSize > 0 && (uint32_t)(eocdBaseSize + commentLength) > maxSize)
throw bad_data();
comment = std::string( buffer + 22, commentLength );

eocdSize = eocdBaseSize + commentLength;
useZip64= false;
}
Expand Down
1 change: 1 addition & 0 deletions src/XrdZip/XrdZipLFH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace XrdZip
from_buffer( uncompressedSize, buffer );
from_buffer( filenameLength, buffer );
from_buffer( extraLength, buffer );

if(bufferSize > 0 && (uint64_t)(lfhBaseSize + filenameLength + extraLength) > bufferSize)
throw bad_data();
// parse the filename
Expand Down
5 changes: 0 additions & 5 deletions tests/XrdEcTests/MicroTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,6 @@ class MicroTest: public CppUnit::TestCase
void UrlNotReachable( size_t index );
void UrlReachable( size_t index );




private:

void AlignedWriteRaw();
Expand All @@ -379,8 +376,6 @@ class MicroTest: public CppUnit::TestCase
std::copy( begin, end, std::back_inserter( rawdata ) );
}



std::string datadir;
std::unique_ptr<ObjCfg> objcfg;
std::vector<std::string> replaceHosts = {"host1", "host2", "host3"};
Expand Down

0 comments on commit 92bd329

Please sign in to comment.