From 2517b79311d862f0e450bd58cb06547793b4cbfd Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Sun, 27 Feb 2011 09:18:46 +1100 Subject: [PATCH] Add missing lock in signal_set_service::cancel(). --- .../include/asio/detail/impl/signal_set_service.ipp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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);