Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readonly file mapping on windows #307

Merged
merged 2 commits into from
Dec 21, 2022

Commits on Nov 26, 2022

  1. Fix readonly file mapping on windows

    `CreateFileMapping` tries to extend the file to the size of mapping
    which leads to failure if database was opened in readonly and calculated
    mmap size is bigger than the file size.
    Providing 0 to `MapViewOfFile` will create a view which has size of
    mapping, i.e. file-size in read-only mode and full size if file was
    truncated.
    
    Also, swap `sizehi` and `sizelo` names to reflect windows API docs.
    This was changed in 1c97a49 for seemingly no reason.
    
    Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
    fyrchik committed Nov 26, 2022
    Configuration menu
    Copy the full SHA
    52d028f View commit details
    Browse the repository at this point in the history
  2. Close CreateFileMapping handle after MapViewOfFile failure

    mmap-go does this, see edsrzf/mmap-go@82d537b
    
    Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
    fyrchik committed Nov 26, 2022
    Configuration menu
    Copy the full SHA
    4504feb View commit details
    Browse the repository at this point in the history