diff options
author | Henning Baldersheim <balder@oath.com> | 2018-09-07 11:29:19 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-09-07 11:29:19 +0200 |
commit | aef6f781072781cc11dac8e7067cc8a72c081c84 (patch) | |
tree | c85c3192539913c3036c608f755b6da19fc574aa /vespamalloc/src | |
parent | f5d5aa3493915e2eb0cda6030f50353ac19785b9 (diff) |
If there are intermediate errors that has no effect on the end result they should affect the 'errno' variable.
Diffstat (limited to 'vespamalloc/src')
-rw-r--r-- | vespamalloc/src/vespamalloc/util/osmem.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/vespamalloc/src/vespamalloc/util/osmem.cpp b/vespamalloc/src/vespamalloc/util/osmem.cpp index 3c72a135d8f..f4fbb376265 100644 --- a/vespamalloc/src/vespamalloc/util/osmem.cpp +++ b/vespamalloc/src/vespamalloc/util/osmem.cpp @@ -150,8 +150,10 @@ void * MmapMemory::get(size_t len) { void * memory(nullptr); + int prevErrno = errno; memory = getHugePages(len); if (memory == nullptr) { + errno = prevErrno; // The temporary error should not impact if the end is good. memory = getNormalPages(len); } return memory; @@ -162,9 +164,11 @@ MmapMemory::getHugePages(size_t len) { void * memory(nullptr); if ( ((len & 0x1fffff) == 0) && len) { + int prevErrno = errno; memory = getBasePages(len, MAP_ANON | MAP_PRIVATE | MAP_HUGETLB, -1, 0); if (memory == nullptr) { if (_hugePagesFd >= 0) { + errno = prevErrno; // The temporary error should not impact if the end is good. memory = getBasePages(len, MAP_SHARED, _hugePagesFd, _hugePagesOffset); if (memory) { _hugePagesOffset += len; |