From: Martin Quinson Date: Thu, 29 Nov 2018 15:15:17 +0000 (+0100) Subject: link_energy: make sure that the watts ranges are always inited correctly X-Git-Tag: v3_22~767 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/50ab353846e7d8e45be8455107deca58b91c0791?ds=sidebyside link_energy: make sure that the watts ranges are always inited correctly Thanks to Loic for the report and debug of this issue. --- diff --git a/src/plugins/link_energy.cpp b/src/plugins/link_energy.cpp index 8bf16970b4..08e0a736a7 100644 --- a/src/plugins/link_energy.cpp +++ b/src/plugins/link_energy.cpp @@ -72,6 +72,9 @@ simgrid::xbt::Extension LinkEnergy::EXTENSION_ID void LinkEnergy::update() { + if (!inited_) + init_watts_range_list(); + double power = get_power(); double now = surf_get_clock(); total_energy_ += power * (now - last_updated_); @@ -80,7 +83,6 @@ void LinkEnergy::update() void LinkEnergy::init_watts_range_list() { - if (inited_) return; inited_ = true; @@ -114,8 +116,6 @@ void LinkEnergy::init_watts_range_list() } catch (std::invalid_argument& ia) { throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname()); } - - update(); } }