summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2015-09-10 14:14:01 +0000
committerKim van der Riet <kpvdr@apache.org>2015-09-10 14:14:01 +0000
commit904455fa706682f6afa686295e88e6d58e4fc866 (patch)
tree6140958fe3a6844cf6319f650f616e57bb2edc39 /qpid/cpp
parent664b5f13a6f9e88e66a0564d15ce7a006777b52c (diff)
downloadqpid-python-904455fa706682f6afa686295e88e6d58e4fc866.tar.gz
NO-JIRA: Improve iostreams error reporting by passing errno to the function that checks the outcome of iostream operations. It is hard to find the value of errno in a core trace, but trivial to print it out at the time the error is detected.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1702258 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp14
-rw-r--r--qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h3
2 files changed, 10 insertions, 7 deletions
diff --git a/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp b/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
index 08db3f75bd..681ced3fd7 100644
--- a/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
+++ b/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
@@ -83,7 +83,7 @@ void EmptyFilePool::initialize() {
}
// Create 'in_use' and 'returned' subdirs if they don't already exist
- // Retern files to EFP in 'in_use' and 'returned' subdirs if they do exist
+ // Return files to EFP in 'in_use' and 'returned' subdirs if they do exist
initializeSubDirectory(efpDirectory_ + "/" + s_inuseFileDirectory_);
initializeSubDirectory(efpDirectory_ + "/" + s_returnedFileDirectory_);
}
@@ -195,7 +195,8 @@ efpDataSize_kib_t EmptyFilePool::dataSizeFromDirName_kib(const std::string& dirN
}
// --- protected functions ---
-void EmptyFilePool::checkIosState(std::ofstream& ofs,
+void EmptyFilePool::checkIosState(const int io_errno,
+ std::ofstream& ofs,
const uint32_t jerrno,
const std::string& fqFileName,
const std::string& operation,
@@ -208,7 +209,8 @@ void EmptyFilePool::checkIosState(std::ofstream& ofs,
}
std::ostringstream oss;
oss << "IO failure: eofbit=" << (ofs.eof()?"T":"F") << " failbit=" << (ofs.fail()?"T":"F") << " badbit="
- << (ofs.bad()?"T":"F") << " file=" << fqFileName << " operation=" << operation << ": " << errorMessage;
+ << (ofs.bad()?"T":"F") << " file=" << fqFileName << FORMAT_SYSERR(io_errno) << ") operation="
+ << operation << ": " << errorMessage;
throw jexception(jerrno, oss.str(), className, fnName);
}
}
@@ -251,13 +253,13 @@ void EmptyFilePool::overwriteFileContents(const std::string& fqFileName) {
::file_hdr_t fh;
::file_hdr_create(&fh, QLS_FILE_MAGIC, QLS_JRNL_VERSION, QLS_JRNL_FHDR_RES_SIZE_SBLKS, partitionPtr_->getPartitionNumber(), efpDataSize_kib_);
std::ofstream ofs(fqFileName.c_str(), std::ofstream::out | std::ofstream::binary);
- checkIosState(ofs, jerrno::JERR_EFP_FOPEN, fqFileName, "constructor", "Failed to create file", "EmptyFilePool", "overwriteFileContents");
+ checkIosState(errno, ofs, jerrno::JERR_EFP_FOPEN, fqFileName, "constructor", "Failed to create file", "EmptyFilePool", "overwriteFileContents");
ofs.write((char*)&fh, sizeof(::file_hdr_t));
- checkIosState(ofs, jerrno::JERR_EFP_FWRITE, fqFileName, "write()", "Failed to write header", "EmptyFilePool", "overwriteFileContents");
+ checkIosState(errno, ofs, jerrno::JERR_EFP_FWRITE, fqFileName, "write()", "Failed to write header", "EmptyFilePool", "overwriteFileContents");
uint64_t rem = ((efpDataSize_kib_ + (QLS_JRNL_FHDR_RES_SIZE_SBLKS * QLS_SBLK_SIZE_KIB)) * 1024) - sizeof(::file_hdr_t);
while (rem--) {
ofs.put('\0');
- checkIosState(ofs, jerrno::JERR_EFP_FWRITE, fqFileName, "put()", "Failed to put \0", "EmptyFilePool", "overwriteFileContents");
+ checkIosState(errno, ofs, jerrno::JERR_EFP_FWRITE, fqFileName, "put()", "Failed to put \0", "EmptyFilePool", "overwriteFileContents");
}
ofs.close();
//std::cout << "*** WARNING: EFP " << efpDirectory_ << " is empty - created new journal file " << fqFileName.substr(fqFileName.rfind('/') + 1) << " on the fly" << std::endl; // DEBUG
diff --git a/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h b/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
index dc567ff917..935057fe2b 100644
--- a/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
+++ b/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
@@ -87,7 +87,8 @@ public:
const efpPartitionNumber_t partitionNumber);
protected:
- void checkIosState(std::ofstream& ofs,
+ void checkIosState(const int io_errno,
+ std::ofstream& ofs,
const uint32_t jerrno,
const std::string& fqFileName,
const std::string& operation,