Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix comment
[simgrid.git] / examples / msg / msg_test.c
index 451dc02..988f18e 100644 (file)
@@ -6,9 +6,11 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
+#include "xbt/sysdep.h" /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
+#include "xbt/asserts.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
 
 int master(int argc, char *argv[]);
@@ -83,6 +85,7 @@ int master(int argc, char *argv[])
     if(MSG_host_self()==slaves[i % slaves_count]) {
       INFO0("Hey ! It's me ! :)");
     }
+
     MSG_task_put(todo[i], slaves[i % slaves_count],
                  PORT_22);
     INFO0("Send completed");
@@ -125,12 +128,12 @@ int slave(int argc, char *argv[])
   return 0;
 } /* end_of_slave */
 
-/** Receiver function */
+/** Forwarder function */
 int forwarder(int argc, char *argv[])
 {
   int i;
-  int slaves_count = argc - 1;
-  m_host_t *slaves = calloc(slaves_count, sizeof(m_host_t));
+  int slaves_count;
+  m_host_t *slaves;
 
   {                  /* Process organisation */
     slaves_count = argc - 1;
@@ -165,6 +168,7 @@ int forwarder(int argc, char *argv[])
                    slaves[i% slaves_count]->name);
       MSG_task_put(task, slaves[i % slaves_count],
                   PORT_22);
+      i++;
     } else {
       INFO0("Hey ?! What's up ? ");
       xbt_assert0(0,"Unexpected behavior");
@@ -175,7 +179,6 @@ int forwarder(int argc, char *argv[])
   return 0;
 } /* end_of_forwarder */
 
-
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
                            const char *application_file)