From: Arnaud Giersch Date: Mon, 24 Jun 2019 14:16:15 +0000 (+0200) Subject: Correctly cancel communications when a link is turned off. X-Git-Tag: v3.23~6 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8d336a6ef3b2aee3aa81de0fbedfaa9971b89fb3 Correctly cancel communications when a link is turned off. Fix https://framagit.org/simgrid/simgrid/issues/26 --- diff --git a/ChangeLog b/ChangeLog index 74b14dbfed..d8a7317c08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,7 @@ General: Python: - Simgrid can now hopefully be installed with pip. -S4U: +S4U: - wait_any can now be used for asynchronous executions too. XBT: @@ -55,6 +55,7 @@ Fixed bugs (FG=FramaGit; GH=GitHub): - FG#20: 'tesh --help' should return 0 - FG#21: Documentation link on http://simgrid.org/ broken - FG#22: Debian installation instruction are broken + - FG#26: Turning off a link should raise NetworkFailureException exceptions - GH#133: Java: a process can run on a VM even if its host is off - GH#320: Stacktrace: Avoid the backtrace variant of Boost.Stacktrace? - GH#326: Valgrind-detected error for join() when energy plugin is activated diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index bf98103912..883578bf6b 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -282,19 +282,7 @@ void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double valu if (value > 0) turn_on(); else { - kernel::lmm::Variable* var = nullptr; - const kernel::lmm::Element* elem = nullptr; - double now = surf_get_clock(); - turn_off(); - while ((var = get_constraint()->get_variable(&elem))) { - Action* action = static_cast(var->get_id()); - - if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) { - action->set_finish_time(now); - action->set_state(Action::State::FAILED); - } - } } tmgr_trace_event_unref(&state_event_); } else { diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index e7d5ad9a54..54f82296d3 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -138,6 +138,17 @@ void LinkImpl::turn_off() if (is_on()) { Resource::turn_off(); s4u::Link::on_state_change(this->piface_); + + kernel::lmm::Variable* var = nullptr; + const kernel::lmm::Element* elem = nullptr; + double now = surf_get_clock(); + while ((var = get_constraint()->get_variable(&elem))) { + Action* action = static_cast(var->get_id()); + if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) { + action->set_finish_time(now); + action->set_state(Action::State::FAILED); + } + } } }