Skip to content

Commit

Permalink
On Windows, use same share mode as files opened via fopen().
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff committed Apr 5, 2022
1 parent 419fd52 commit fc15d16
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/boost/asio/detail/impl/win_iocp_file_service.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ boost::system::error_code win_iocp_file_service::open(
else if ((open_flags & file_base::read_write) != 0)
access = GENERIC_READ | GENERIC_WRITE;

DWORD share = FILE_SHARE_READ | FILE_SHARE_WRITE;

DWORD disposition = 0;
if ((open_flags & file_base::create) != 0)
{
Expand All @@ -92,7 +94,7 @@ boost::system::error_code win_iocp_file_service::open(
if ((open_flags & file_base::sync_all_on_write) != 0)
flags |= FILE_FLAG_WRITE_THROUGH;

HANDLE handle = ::CreateFileA(path, access, 0, 0, disposition, flags, 0);
HANDLE handle = ::CreateFileA(path, access, share, 0, disposition, flags, 0);
if (handle != INVALID_HANDLE_VALUE)
{
if (disposition == OPEN_ALWAYS && (open_flags & file_base::truncate) != 0)
Expand Down

0 comments on commit fc15d16

Please sign in to comment.