Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't loose first result for 'failed'.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 24 Apr 2018 11:51:38 +0000 (13:51 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 24 Apr 2018 19:19:58 +0000 (21:19 +0200)
src/surf/network_cm02.cpp

index 45140ed..34d8881 100644 (file)
@@ -242,7 +242,6 @@ void NetworkCm02Model::update_actions_state_full(double now, double delta)
 
 Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
 {
-  bool failed    = false;
   double latency = 0.0;
   std::vector<LinkImpl*> back_route;
   std::vector<LinkImpl*> route;
@@ -254,11 +253,12 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
              "You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
              src->get_cname(), dst->get_cname());
 
-  failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
+  bool failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
 
   if (cfg_crosstraffic) {
     dst->routeTo(src, back_route, nullptr);
-    failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
+    if (not failed)
+      failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
   }
 
   NetworkCm02Action *action = new NetworkCm02Action(this, size, failed);