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

Return if stopped_ is not zero at the begining of loop in do_one #1544

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions asio/include/asio/detail/impl/win_iocp_io_context.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,13 @@ size_t win_iocp_io_context::do_one(DWORD msec,
{
for (;;)
{
// Check if the context has been stopped
if (::InterlockedExchangeAdd(&stopped_, 0) != 0)
{
ec = asio::error_code();
return 0;
}

// Try to acquire responsibility for dispatching timers and completed ops.
if (::InterlockedCompareExchange(&dispatch_required_, 0, 1) == 1)
{
Expand Down