aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar
diff options
context:
space:
mode:
authorGravatar Reker <imReker@users.noreply.github.com>2016-11-24 15:12:30 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-11-24 15:54:45 +0000
commitb51a8cb05ae989815157d82ed86cfa3a6fbf53fc (patch)
treeb51274fe1ec2d542370986e70bc8b8ba3b9c6db9 /third_party/ijar
parent468ecdc36d841819642bc86a5e4e36998c07dcee (diff)
Adapt ijar for WSL
The behavior of ftruncate on WSL is not same as standard Linux due to a bug, it'll fail on maped file. This commit fix the bug by munmap the file before ftruncate. Closes #2108. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/2108 MOS_MIGRATED_REVID=140134115
Diffstat (limited to 'third_party/ijar')
-rw-r--r--third_party/ijar/mapped_file_unix.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/third_party/ijar/mapped_file_unix.cc b/third_party/ijar/mapped_file_unix.cc
index f7668a517c..d5a0b57cac 100644
--- a/third_party/ijar/mapped_file_unix.cc
+++ b/third_party/ijar/mapped_file_unix.cc
@@ -87,6 +87,7 @@ int MappedInputFile::Close() {
struct MappedOutputFileImpl {
int fd_;
+ int mmap_length_;
};
MappedOutputFile::MappedOutputFile(const char* name, u8 estimated_size) {
@@ -119,6 +120,7 @@ MappedOutputFile::MappedOutputFile(const char* name, u8 estimated_size) {
impl_ = new MappedOutputFileImpl();
impl_->fd_ = fd;
+ impl_->mmap_length_ = mmap_length;
buffer_ = reinterpret_cast<u1*>(mapped);
opened_ = true;
}
@@ -129,6 +131,7 @@ MappedOutputFile::~MappedOutputFile() {
}
int MappedOutputFile::Close(int size) {
+ munmap(buffer_, impl_->mmap_length_);
if (ftruncate(impl_->fd_, size) < 0) {
snprintf(errmsg, MAX_ERROR, "ftruncate(): %s", strerror(errno));
errmsg_ = errmsg;