X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f21d89e2df9b398e4e6f422d253b2eed951f45d6..471ed269e1475136aa0d459301b90c86960206e2:/examples/s4u/dht-chord/s4u-dht-chord-node.cpp diff --git a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp index 93af0361da..1af602aa40 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp @@ -498,7 +498,15 @@ void Node::operator()() while (now < std::min(start_time_ + deadline_, MAX_SIMULATION_TIME)) { if (comm_receive == nullptr) comm_receive = mailbox_->get_async(&data); - if (comm_receive->test()) { + bool comm_completed = true; + try { + if (not comm_receive->test()) + comm_completed = false; + } catch (const simgrid::TimeoutException&) { + XBT_DEBUG("Caught a timeout, go ahead."); + } + + if (comm_completed) { if (data != nullptr) { ChordMessage* message = static_cast(data); handleMessage(message); @@ -528,10 +536,14 @@ void Node::operator()() now = simgrid::s4u::Engine::get_clock(); } if (comm_receive != nullptr) { - if (comm_receive->test()) - delete static_cast(data); - else - comm_receive->cancel(); + try { + if (comm_receive->test()) + delete static_cast(data); + else + comm_receive->cancel(); + } catch (const simgrid::TimeoutException&) { + XBT_DEBUG("Caught a timeout for last message, nevermind."); + } } // leave the ring leave();