From: Frederic Suter Date: Thu, 21 Feb 2019 19:29:21 +0000 (+0100) Subject: fix some issues with Cancel X-Git-Tag: v3_22~276 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/370d85c0bc1fd13c8444a243ecd4390012f5c246 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. --- 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; }