Skip to content

SHARED WRITE Support on memory mapped files (Windows) #178

Description

@piesarmin

We have been using the Boost libraries for at least 14 years. Unfortunately, since that time, we have had to patch a file with every new release in order to use the iostreams library on Windows.
That never had been a problem under Unix or Linux.

The file in question is from boost::iostreams. It is \libs\iostreams\src\mapped_file.cpp.

The actual code only allows shared read access to the opened file by calling

      ::CreateFileA( 
            p.path.c_str(),
            dwDesiredAccess,
            FILE_SHARE_READ,
            NULL,
            dwCreationDisposition,
            dwFlagsandAttributes,
            NULL );

We have to change FILE_SHARE_READ to FILE_SHARE_READ | FILE_SHARE_WRITE:

      ::CreateFileA( 
            p.path.c_str(),
            dwDesiredAccess,
            FILE_SHARE_READ | FILE_SHARE_WRITE,
            NULL,
            dwCreationDisposition,
            dwFlagsandAttributes,
            NULL );

Background: We open a part of a file read-only in our application in multiple threads or processes per memory mapping while we allow one other thread or process to append data at the actual end of the file.

We opened an issue at that time (link to the old ticket system: https://svn.boost.org/trac/boost/ticket/5595 ), but somehow never received any feedback. Eventually, we gave up.

We hope that someone will address this issue now (maybe there’s also another workaround).

Best regards,
Armin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions