summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-26 04:01:53 +0000
committerdgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-26 04:01:53 +0000
commitabb786b1feaabd3318a436fac1245d978581fad1 (patch)
treed505f70484ad6b41ad4773aa22283047e985e268
parent4dc8154d0bf3c318eaa46f4c92962d0b1b371526 (diff)
downloadchromium_src-abb786b1feaabd3318a436fac1245d978581fad1.zip
chromium_src-abb786b1feaabd3318a436fac1245d978581fad1.tar.gz
chromium_src-abb786b1feaabd3318a436fac1245d978581fad1.tar.bz2
Save errno for logging before potentially overwriting it.
There are a few places in ChromiumEnv where errno is written to, then a line of code runs, then errno is logged. That intermediate line may have overwritten errno, so save it before logging it. Review URL: https://chromiumcodereview.appspot.com/17756002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208610 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--third_party/leveldatabase/env_chromium.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc
index 4a8027b..36aa796 100644
--- a/third_party/leveldatabase/env_chromium.cc
+++ b/third_party/leveldatabase/env_chromium.cc
@@ -205,9 +205,10 @@ class ChromiumSequentialFile: public SequentialFile {
virtual Status Skip(uint64_t n) {
if (fseek(file_, n, SEEK_CUR)) {
+ int saved_errno = errno;
uma_logger_->RecordErrorAt(kSequentialFileSkip);
return MakeIOError(
- filename_, strerror(errno), kSequentialFileSkip, errno);
+ filename_, strerror(saved_errno), kSequentialFileSkip, saved_errno);
}
return Status::OK();
}
@@ -471,8 +472,10 @@ Status ChromiumWritableFile::Append(const Slice& data) {
size_t r = fwrite_wrapper(data.data(), 1, data.size(), file_);
if (r != data.size()) {
- uma_logger_->RecordOSError(kWritableFileAppend, errno);
- return MakeIOError(filename_, strerror(errno), kWritableFileAppend, errno);
+ int saved_errno = errno;
+ uma_logger_->RecordOSError(kWritableFileAppend, saved_errno);
+ return MakeIOError(
+ filename_, strerror(saved_errno), kWritableFileAppend, saved_errno);
}
return Status::OK();
}
@@ -583,8 +586,10 @@ Status ChromiumEnv::NewWritableFile(const std::string& fname,
*result = NULL;
FILE* f = fopen_internal(fname.c_str(), "wb");
if (f == NULL) {
+ int saved_errno = errno;
RecordErrorAt(kNewWritableFile);
- return MakeIOError(fname, strerror(errno), kNewWritableFile, errno);
+ return MakeIOError(
+ fname, strerror(saved_errno), kNewWritableFile, saved_errno);
} else {
*result = new ChromiumWritableFile(fname, f, this, this);
return Status::OK();