julia
bf25dcda - fix Mmap.sync! for array mapped from an offset

Commit
9 years ago
fix Mmap.sync! for array mapped from an offset This fixes error when calling `Mmap.sync!` on an array that is not memory mapped from a pagesized offset of a file. ```` julia> using Base.Mmap julia> f = open("arrayfile", "r+"); julia> A = Mmap.mmap(f, Vector{Int64}, (200,), 0); julia> Mmap.sync!(A) julia> B = Mmap.mmap(f, Vector{Int64}, (200,), 8); julia> Mmap.sync!(B) ERROR: SystemError: msync: Invalid argument [inlined code] from ./int.jl:33 in sync!(Base.Mmap.#sync!, Array{Int64,1}, Int64) at ./mmap.jl:207 (repeats 2 times) in eval at ./boot.jl:267 ```` Since `Mmap.mmap` maps from the beginning of a page boundary, `pointer(A)` is not at the page boundary when an offset is provided. But since the pointer returned from `mmap` is aligned at page boundary, `sync!` now recalculates the offset before calling `msync!`. ```` julia> using Base.Mmap julia> f = open("arrayfile", "r+"); julia> B = Mmap.mmap(f, Vector{Int64}, (200,), 8); julia> Mmap.sync!(B) ```` (cherry picked from commit fc9fd22181664b4c61c52dfcf973ab919529bf49) ref #14885
Author
Committer
Parents
Loading