Skip to content

Commit

Permalink
XrdTpc: Always check and fail on error.
Browse files Browse the repository at this point in the history
Cover a few missing returns on error; without this, the code runs
the danger of going into a recursive loop and crashing the process.
  • Loading branch information
bbockelm committed Jan 24, 2021
1 parent 22d1d31 commit c4911d7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/XrdTpc/XrdTpcStream.cc
Expand Up @@ -87,6 +87,9 @@ Stream::Write(off_t offset, const char *buf, size_t size, bool force)
if (!msg || (*msg == '\0')) {msg = "(no error message provided)";}
ss << msg << " (code=" << m_fh->error.getErrInfo() << ")";
m_error_buf = ss.str();
// Write failed; we don't care if there's any more buffer we
// can dump to disk later.
return retval;
}
// If there are no in-use buffers, then we don't need to
// do any accounting.
Expand All @@ -109,9 +112,11 @@ Stream::Write(off_t offset, const char *buf, size_t size, bool force)
entry_iter++) {
// Always try to dump from memory; when size == 0, then we are
// going to force a flush even if things are not MB-aligned.
if ((*entry_iter)->Write(*this, size == 0) > 0) {
buffer_was_written = true;
int retval2 = (*entry_iter)->Write(*this, size == 0);
if (retval2 == SFS_ERROR) {
return retval2;
}
buffer_was_written |= retval2 > 0;
if ((*entry_iter)->Available()) { // Empty buffer
if (!avail_entry) {avail_entry = *entry_iter;}
avail_count ++;
Expand Down

0 comments on commit c4911d7

Please sign in to comment.