From 370d85c0bc1fd13c8444a243ecd4390012f5c246 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Thu, 21 Feb 2019 20:29:21 +0100 Subject: [PATCH 1/1] fix some issues with Cancel * Comm::cancel can be called when there is no pimpl * if we wait for a canceled activity we can return not let the impossible happen. --- src/s4u/s4u_Comm.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 50eaf00d28..7eb4685229 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -167,6 +167,8 @@ Comm* Comm::wait_for(double timeout) state_ = State::FINISHED; return this; + case State::CANCELED: + return this; default: THROW_IMPOSSIBLE; } @@ -193,7 +195,10 @@ Comm* Comm::detach() Comm* Comm::cancel() { - simgrid::simix::simcall([this] { static_cast(pimpl_.get())->cancel(); }); + simgrid::simix::simcall([this] { + if (pimpl_) + boost::static_pointer_cast(pimpl_)->cancel(); + }); state_ = State::CANCELED; return this; } -- 2.20.1