diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2022-04-28 07:39:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-28 08:28:54 +0000 |
commit | 5b17ba836945f2b7cbcc77a643311f41fe7b7b6e (patch) | |
tree | 11aa849763d123d755eb0d9c30215904acdef4c2 /src/mongo/util/procparser.cpp | |
parent | 30260c79d9e09dee6c68637f87db6c4bdf16cbfe (diff) | |
download | mongo-5b17ba836945f2b7cbcc77a643311f41fe7b7b6e.tar.gz |
SERVER-41353 replace errnoWithDescription with an API based on std::error_code
Diffstat (limited to 'src/mongo/util/procparser.cpp')
-rw-r--r-- | src/mongo/util/procparser.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/util/procparser.cpp b/src/mongo/util/procparser.cpp index 599608c9cc8..c1d85bbf71a 100644 --- a/src/mongo/util/procparser.cpp +++ b/src/mongo/util/procparser.cpp @@ -92,10 +92,10 @@ constexpr auto kSysBlockDeviceDirectoryName = "device"; StatusWith<std::string> readFileAsString(StringData filename) { int fd = open(filename.toString().c_str(), 0); if (fd == -1) { - int err = errno; + auto ec = lastSystemError(); return Status(ErrorCodes::FileOpenFailed, str::stream() << "Failed to open file " << filename - << " with error: " << errnoWithDescription(err)); + << " with error: " << errorMessage(ec)); } ScopeGuard scopedGuard([fd] { close(fd); }); @@ -114,17 +114,18 @@ StatusWith<std::string> readFileAsString(StringData filename) { size_read = read(fd, buf.data(), kFileBufferSize); if (size_read == -1) { - int err = errno; + auto ec = lastPosixError(); - // Retry if we hit EGAIN or EINTR a few times before giving up - if (retry < kFileReadRetryCount && (err == EAGAIN || err == EINTR)) { + // Retry if we hit EAGAIN or EINTR a few times before giving up + if (retry < kFileReadRetryCount && + (ec == posixError(EAGAIN) || ec == posixError(EINTR))) { ++retry; continue; } return Status(ErrorCodes::FileStreamFailed, str::stream() << "Failed to read file " << filename - << " with error: " << errnoWithDescription(err)); + << " with error: " << errorMessage(ec)); } break; |