Commit 3f6f783a authored by Steven Murray's avatar Steven Murray
Browse files

cta/CTA#139 cta af ls --vid XXXXX command times out if there are many files on a tape

The "cta af ls" command now sends several rows back to the client
in a single reply.
parent 8a7e1402
......@@ -157,27 +157,21 @@ int sendCommand(const int argc, const char **argv) {
{
uint64_t readOffset = 1; // The first character at offset 0 has already been read
uint32_t bytesRead = 0;
const size_t bufSize = 20480;
std::unique_ptr<char []> buf(new char[bufSize]);
do {
bytesRead = 0;
char buf[1024];
memset(buf, 0, sizeof(buf));
const XrdCl::XRootDStatus readStatus = xrootFile.Read(readOffset, sizeof(buf) - 1, buf, bytesRead);
memset(buf.get(), 0, bufSize);
const XrdCl::XRootDStatus readStatus = xrootFile.Read(readOffset, bufSize - 1, buf.get(), bytesRead);
if(!readStatus.IsOK()) {
throw std::runtime_error(std::string("Failed to read ") + cmdPath + ": " + readStatus.ToStr());
}
if(bytesRead > 0) {
for(std::string::size_type i = 0; i < bytesRead; i++) {
const char c = buf[i];
if(0 == c) {
std::cout << "<NULL>";
} else {
std::cout << c;
}
}
std::cout << buf.get();
if(writeToStderr) {
std::cerr<<buf;
std::cerr << buf.get();
}
}
......
......@@ -111,10 +111,15 @@ XrdSfsXferSize ListArchiveFilesCmd::read(XrdSfsFileOffset offset, char *buffer,
// refreshReadBuffer
//------------------------------------------------------------------------------
void ListArchiveFilesCmd::refreshReadBuffer() {
// Note that one archive file may have more than one tape file
const uint32_t nbArchiveFilesToFetch = 100;
uint32_t nbFetchedArchiveFiles = 0;
m_readBuffer.clear();
if(m_archiveFileItor->hasMore()) {
while(m_archiveFileItor->hasMore() && nbArchiveFilesToFetch > nbFetchedArchiveFiles) {
const common::dataStructures::ArchiveFile archiveFile = m_archiveFileItor->next();
nbFetchedArchiveFiles++;
for(auto copyNbToTapeFile: archiveFile.tapeFiles) {
const auto copyNb = copyNbToTapeFile.first;
const common::dataStructures::TapeFile &tapeFile = copyNbToTapeFile.second;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment