Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean MSG source file names
[simgrid.git] / src / msg / msg_mailbox.c
index 6700ed7..41e6f14 100644 (file)
@@ -6,8 +6,8 @@
 /* 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. */
 
-#include "mailbox.h"
-#include "msg/private.h"
+#include "msg_mailbox.h"
+#include "msg_private.h"
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_mailbox, msg,
                                 "Logging specific to MSG (mailbox)");
 
@@ -58,8 +58,8 @@ msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
 msg_mailbox_t MSG_mailbox_get_by_channel(m_host_t host,
                                          m_channel_t channel)
 {
-  xbt_assert0((host != NULL), "Invalid host");
-  xbt_assert1((channel >= 0)
+  xbt_assert((host != NULL), "Invalid host");
+  xbt_assert((channel >= 0)
               && (channel < msg_global->max_channel), "Invalid channel %d",
               channel);
 
@@ -83,11 +83,11 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
 #endif
 
   /* Sanity check */
-  xbt_assert0(task, "Null pointer for the task storage");
+  xbt_assert(task, "Null pointer for the task storage");
 
   if (*task)
-    XBT_CRITICAL
-        ("MSG_task_get() was asked to write in a non empty task struct.");
+    XBT_WARN
+        ("Asked to write the received task in a non empty struct -- proceeding.");
 
   /* Try to receive it by calling SIMIX network layer */
   TRY {
@@ -131,14 +131,10 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   simdata_task_t t_simdata = NULL;
   m_process_t process = MSG_process_self();
   simdata_process_t p_simdata = SIMIX_process_self_get_data();
-#ifdef HAVE_TRACING
-  volatile smx_action_t comm = NULL;
-  int call_end = 0;
-#endif
   CHECK_HOST();
 
 #ifdef HAVE_TRACING
-  call_end = TRACE_msg_task_put_start(task);    //must be after CHECK_HOST()
+  int call_end = TRACE_msg_task_put_start(task);    //must be after CHECK_HOST()
 #endif
 
   /* Prepare the task to send */
@@ -146,7 +142,7 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   t_simdata->sender = process;
   t_simdata->source = MSG_host_self();
 
-  xbt_assert0(t_simdata->isused == 0,
+  xbt_assert(t_simdata->isused == 0,
               "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
 
   t_simdata->isused=1;
@@ -158,14 +154,19 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   /* Try to send it by calling SIMIX network layer */
   TRY {
 #ifdef HAVE_TRACING
-    comm = SIMIX_req_comm_isend(mailbox, t_simdata->message_size,
-        t_simdata->rate, task, sizeof(void *), NULL, NULL, 0);
-    t_simdata->comm = comm;
-    SIMIX_req_set_category(comm, task->category);
-    SIMIX_req_comm_wait(comm, timeout);
-#else
-    SIMIX_req_comm_send(mailbox, t_simdata->message_size,
-        t_simdata->rate, task, sizeof(void*), NULL, NULL, timeout);
+    if (TRACE_is_enabled()) {
+      smx_action_t comm = SIMIX_req_comm_isend(mailbox, t_simdata->message_size,
+                                  t_simdata->rate, task, sizeof(void *),
+                                  NULL, NULL, 0);
+      SIMIX_req_set_category(comm, task->category);
+      SIMIX_req_comm_wait(comm, timeout);
+    } else {
+#endif
+      SIMIX_req_comm_send(mailbox, t_simdata->message_size,
+                          t_simdata->rate, task, sizeof(void*),
+                          NULL, NULL, timeout);
+#ifdef HAVE_TRACING
+    }
 #endif
   }