diff --git a/asio/include/asio/detail/impl/signal_set_service.ipp b/asio/include/asio/detail/impl/signal_set_service.ipp index 671a458b..a4d623c5 100644 --- a/asio/include/asio/detail/impl/signal_set_service.ipp +++ b/asio/include/asio/detail/impl/signal_set_service.ipp @@ -393,11 +393,16 @@ asio::error_code signal_set_service::cancel( ASIO_HANDLER_OPERATION(("signal_set", &impl, "cancel")); op_queue ops; - while (signal_op* op = impl.queue_.front()) { - op->ec_ = asio::error::operation_aborted; - impl.queue_.pop(); - ops.push(op); + signal_state* state = get_signal_state(); + static_mutex::scoped_lock lock(state->mutex_); + + while (signal_op* op = impl.queue_.front()) + { + op->ec_ = asio::error::operation_aborted; + impl.queue_.pop(); + ops.push(op); + } } io_service_.post_deferred_completions(ops);