Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove the public field msg_host_t->name. Use MSG_host_get_name()
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 27 Apr 2012 20:47:02 +0000 (22:47 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 27 Apr 2012 20:49:39 +0000 (22:49 +0200)
13 files changed:
ChangeLog
examples/msg/masterslave/masterslave_bypass.c
examples/msg/masterslave/masterslave_cluster.c
examples/msg/masterslave/masterslave_failure.c
examples/msg/masterslave/masterslave_forwarder.c
examples/msg/migration/migration.c
examples/msg/tracing/ms.c
examples/msg/tracing/user_variables.c
include/msg/datatypes.h
src/instr/instr_msg_process.c
src/msg/msg_gos.c
src/msg/msg_host.c
src/msg/msg_process.c

index 5583490..11162e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@ SimGrid (3.7) NOT RELEASED; urgency=low
   * Deprecate MSG_get_host_{table,number}
     Implement MSG_hosts_as_dynar() instead.
   * Implement MSG_processes_as_dynar() (Closes gforge #13642)
+  * Remove the public field msg_host_t->name. Use MSG_host_get_name()
 
   Simix:
   * Stabilize the parallel execution mode of user contexts
index 4c6f2a8..343c92f 100644 (file)
@@ -199,7 +199,7 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Got %d slave(s) :", slaves_count);
   for (i = 0; i < slaves_count; i++)
-    XBT_INFO("\t %s", slaves[i]->name);
+    XBT_INFO("\t %s", MSG_host_get_name(slaves[i]));
 
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
@@ -208,7 +208,7 @@ int master(int argc, char *argv[])
 
   for (i = 0; i < number_of_tasks; i++) {
     XBT_INFO("Sending \"%s\" to \"%s\"",
-          todo[i]->name, slaves[i % slaves_count]->name);
+          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
index 6f871fd..1e54f5e 100644 (file)
@@ -69,7 +69,7 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Got %d slave(s) :", slaves_count);
   for (i = 0; i < slaves_count; i++)
-    XBT_INFO("\t %s", slaves[i]->name);
+    XBT_INFO("\t %s", MSG_host_get_name(slaves[i]));
 
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
@@ -78,7 +78,7 @@ int master(int argc, char *argv[])
 
   for (i = 0; i < number_of_tasks; i++) {
     XBT_INFO("Sending \"%s\" to \"%s\"",
-          todo[i]->name, slaves[i % slaves_count]->name);
+          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
index c882244..39e7d7e 100644 (file)
@@ -55,7 +55,7 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Got %d slave(s) :", slaves_count);
   for (i = 0; i < slaves_count; i++)
-    XBT_INFO("%s", slaves[i]->name);
+    XBT_INFO("%s", MSG_host_get_name(slaves[i]));
 
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
@@ -79,13 +79,13 @@ int master(int argc, char *argv[])
     } else if (a == MSG_TRANSFER_FAILURE) {
       XBT_INFO
           ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!",
-           slaves[i % slaves_count]->name);
+              MSG_host_get_name(slaves[i % slaves_count]));
       free(task->data);
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       XBT_INFO
           ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
-           slaves[i % slaves_count]->name);
+              MSG_host_get_name(slaves[i % slaves_count]));
       free(task->data);
       MSG_task_destroy(task);
     } else {
@@ -109,16 +109,16 @@ int master(int argc, char *argv[])
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       XBT_INFO("Mmh. Can't reach '%s'! Nevermind. Let's keep going!",
-            slaves[i]->name);
+          MSG_host_get_name(slaves[i]));
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       XBT_INFO
           ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
-           slaves[i % slaves_count]->name);
+              MSG_host_get_name(slaves[i % slaves_count]));
       MSG_task_destroy(task);
     } else {
       XBT_INFO("Hey ?! What's up ? ");
-      xbt_die("Unexpected behavior with '%s': %d", slaves[i]->name, a);
+      xbt_die("Unexpected behavior with '%s': %d", MSG_host_get_name(slaves[i]), a);
     }
   }
 
index 1e0d779..4ebb580 100644 (file)
@@ -77,11 +77,11 @@ int master(int argc, char *argv[])
   XBT_INFO("Got %d slaves and %d tasks to process", slaves_count,
         number_of_tasks);
   for (i = 0; i < slaves_count; i++)
-    XBT_DEBUG("%s", slaves[i]->name);
+    XBT_DEBUG("%s", MSG_host_get_name(slaves[i]));
 
   for (i = 0; i < number_of_tasks; i++) {
     XBT_INFO("Sending \"%s\" to \"%s\"",
-          todo[i]->name, slaves[i % slaves_count]->name);
+          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
@@ -165,7 +165,7 @@ int forwarder(int argc, char *argv[])
         break;
       }
       XBT_INFO("Sending \"%s\" to \"%s\"",
-            MSG_task_get_name(task), slaves[i % slaves_count]->name);
+            MSG_task_get_name(task), MSG_host_get_name(slaves[i % slaves_count]));
       MSG_task_send(task, MSG_host_get_name(slaves[i % slaves_count]));
       i++;
     } else {
index f0ec596..898ac25 100644 (file)
@@ -46,7 +46,7 @@ static int emigrant(int argc, char *argv[])
   xbt_mutex_release(mutex);
   MSG_process_suspend(MSG_process_self());
   m_host_t h = MSG_process_get_host(MSG_process_self());
-  XBT_INFO("I've been moved on this new host: %s", h->name);
+  XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
   XBT_INFO("Uh, nothing to do here. Stopping now");
   return 0;
 }                               /* end_of_emigrant */
index 95b3a28..0b75720 100644 (file)
@@ -41,7 +41,7 @@ int master(int argc, char *argv[])
   long slaves_count = atol(argv[4]);
 
   //setting the variable "is_master" (previously declared) to value 1
-  TRACE_host_variable_set(MSG_host_self()->name, "is_master", 1);
+  TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_master", 1);
 
   TRACE_mark("msmark", "start_send_tasks");
   int i;
@@ -50,7 +50,7 @@ int master(int argc, char *argv[])
     task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
 
     //setting the variable "task_creation" to value i
-    TRACE_host_variable_set(MSG_host_self()->name, "task_creation", i);
+    TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "task_creation", i);
 
     //setting the category of task to "compute"
     //the category of a task must be defined before it is sent or executed
@@ -73,7 +73,7 @@ int slave(int argc, char *argv[])
 {
   m_task_t task = NULL;
 
-  TRACE_host_variable_set(MSG_host_self()->name, "is_slave", 1);
+  TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_slave", 1);
   while (1) {
     MSG_task_receive(&(task), "master_mailbox");
 
@@ -83,7 +83,7 @@ int slave(int argc, char *argv[])
     }
     //adding the value returned by MSG_task_get_compute_duration(task)
     //to the variable "task_computation"
-    TRACE_host_variable_add(MSG_host_self()->name,
+    TRACE_host_variable_add(MSG_host_get_name(MSG_host_self()),
                             "task_computation",
                             MSG_task_get_compute_duration(task));
     MSG_task_execute(task);
index ea2b959..6c63b9d 100644 (file)
@@ -27,7 +27,7 @@ int master(int argc, char *argv[]);
 
 int master(int argc, char *argv[])
 {
-  char *hostname = MSG_host_self()->name;
+  const char *hostname = MSG_host_get_name(MSG_host_self());
   int i;
 
   //the hostname has an empty HDD with a capacity of 100000 (bytes)
index b95dfd9..79fc90a 100644 (file)
@@ -31,7 +31,6 @@ typedef struct s_smx_rvpoint *msg_mailbox_t;
 /* ******************************** Host ************************************ */
 
 typedef struct m_host {
-  char *name;                   /**< @brief host name if any */
   smx_host_t smx_host;          /**< SIMIX representation of this host   */
 #ifdef MSG_USE_DEPRECATED
   msg_mailbox_t *mailboxes;     /**< the channels  */
index fc96c0c..c1a8154 100644 (file)
@@ -45,7 +45,7 @@ void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_hos
     PJ_container_free(existing_container);
 
     //create new container on the new_host location
-    msg = PJ_container_new(instr_process_id(process, str, len), INSTR_MSG_PROCESS, PJ_container_get(new_host->name));
+    msg = PJ_container_new(instr_process_id(process, str, len), INSTR_MSG_PROCESS, PJ_container_get(SIMIX_host_get_name(new_host->smx_host)));
 
     //end link
     msg = PJ_container_get(instr_process_id(process, str, len));
@@ -60,7 +60,7 @@ void TRACE_msg_process_create (const char *process_name, int process_pid, m_host
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t host_container = PJ_container_get (host->name);
+    container_t host_container = PJ_container_get (SIMIX_host_get_name(host->smx_host));
     PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container);
   }
 }
index 60dd791..5081378 100644 (file)
@@ -175,7 +175,7 @@ MSG_error_t MSG_parallel_task_execute(m_task_t task)
   xbt_assert(simdata->host_nb,
               "This is not a parallel task. Go to hell.");
 
-  XBT_DEBUG("Parallel computing on %s", p_simdata->m_host->name);
+  XBT_DEBUG("Parallel computing on %s", SIMIX_host_get_name(p_simdata->m_host->smx_host));
 
   simdata->isused=1;
 
index 40d0ef4..92f2cf1 100644 (file)
 /********************************* Host **************************************/
 m_host_t __MSG_host_create(smx_host_t workstation)
 {
-  const char *name;
+  const char *name = SIMIX_host_get_name(workstation);
   m_host_t host = xbt_new0(s_m_host_t, 1);
 
-  name = SIMIX_host_get_name(workstation);
-  /* Host structure */
-  host->name = xbt_strdup(name);
-
   host->smx_host = workstation;
 
 #ifdef MSG_USE_DEPRECATED
@@ -109,11 +105,8 @@ void *MSG_host_get_data(m_host_t host)
  * This functions checks whether \a host is a valid pointer or not and return
    its name.
  */
-const char *MSG_host_get_name(m_host_t host)
-{
-
-  /* Return data */
-  return (host->name);
+const char *MSG_host_get_name(m_host_t host) {
+  return SIMIX_host_get_name(host->smx_host);
 }
 
 /** \ingroup m_host_management
@@ -127,22 +120,15 @@ m_host_t MSG_host_self(void)
 
 /** \ingroup m_host_management
  *
- * \brief Destroys a host
+ * \brief Destroys a host (internal call only)
  */
-void __MSG_host_destroy(m_host_t host)
-{
-
-  xbt_assert((host != NULL), "Invalid parameters");
-
-  /* Clean simulator data */
+void __MSG_host_destroy(m_host_t host) {
 
 #ifdef MSG_USE_DEPRECATED
   if (msg_global->max_channel > 0)
     free(host->mailboxes);
 #endif
 
-  /* Clean host structure */
-  free(host->name);
   free(host);
 }
 
index 60e0386..dcd5a8c 100644 (file)
@@ -174,7 +174,7 @@ m_process_t MSG_process_create_with_environment(const char *name,
 
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
-  simcall_process_create(&process, name, code, simdata, host->name,
+  simcall_process_create(&process, name, code, simdata, SIMIX_host_get_name(host->smx_host),
                            argc, argv, properties);
 
   if (!process) {