From 50ab353846e7d8e45be8455107deca58b91c0791 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 29 Nov 2018 16:15:17 +0100 Subject: [PATCH] link_energy: make sure that the watts ranges are always inited correctly Thanks to Loic for the report and debug of this issue. --- src/plugins/link_energy.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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(); } } -- 2.20.1