Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix the depends of iSend/iRecv vs. WaitComm to fix the bugged2 example
[simgrid.git] / examples / cpp / mc-bugged2 / s4u-mc-bugged2.cpp
index ea27c72466c50a964260b8e093fa4eb153520566..1f6d3c3abc56b8082218881331df22edd7b0fb1a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,25 +20,25 @@ static void server()
 
   received1 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   long val1 = *received1;
-  received1 = nullptr;
-  XBT_INFO("Received %ld", val1);
+  delete received1;
 
   received2 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   long val2 = *received2;
-  received2 = nullptr;
-  XBT_INFO("Received %ld", val2);
+  delete received2;
 
-  MC_assert(std::min(val1, val2) == 1);
+  XBT_INFO("First pair received: %ld %ld", val1, val2);
+
+  MC_assert(std::min(val1, val2) == 1); // if the two messages of the second client arrive first, this is violated.
 
   received1 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   val1      = *received1;
-  XBT_INFO("Received %ld", val1);
+  delete received1;
 
   received2 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   val2      = *received2;
-  XBT_INFO("Received %ld", val2);
+  delete received2;
 
-  XBT_INFO("OK");
+  XBT_INFO("Second pair received: %ld %ld", val1, val2);
 }
 
 static void client(int id)
@@ -46,10 +46,7 @@ static void client(int id)
   auto* payload1 = new int(id);
   auto* payload2 = new int(id);
 
-  XBT_INFO("Send %d", id);
   simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload1, 10000);
-
-  XBT_INFO("Send %d", id);
   simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload2, 10000);
 }