Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Dont declare variables at the middle of nowhere.
[simgrid.git] / src / msg / msg_mailbox.c
index c0e97dc..ab3e89f 100644 (file)
@@ -1,3 +1,11 @@
+/* Mailboxes in MSG */
+
+/* Copyright (c) 2008, 2009, 2010. 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. */
+
 #include "mailbox.h"
 #include "msg/private.h"
 
@@ -111,11 +119,17 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t *task, m_host_t host,
   xbt_ex_t e;
   MSG_error_t ret = MSG_OK;
   smx_comm_t comm;
-
+#ifdef HAVE_TRACING
+  double start_time = 0;
+#endif
   /* We no longer support getting a task from a specific host */
   if (host) THROW_UNIMPLEMENTED;
 
   CHECK_HOST();
+#ifdef HAVE_TRACING
+  TRACE_msg_task_get_start ();
+  start_time = MSG_get_clock();
+#endif
 
   memset(&comm,0,sizeof(comm));
 
@@ -145,14 +159,21 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t *task, m_host_t host,
         ret = MSG_TRANSFER_FAILURE;
         break;
       case timeout_error:
-        ret = MSG_TIMEOUT_FAILURE;
+        ret = MSG_TIMEOUT;
         break;      
       default:
         xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
     }
     xbt_ex_free(e);        
   }
-  
+
+  if (ret != MSG_HOST_FAILURE &&
+      ret != MSG_TRANSFER_FAILURE &&
+      ret != MSG_TIMEOUT){
+#ifdef HAVE_TRACING
+    TRACE_msg_task_get_end (start_time, *task);
+#endif
+  }
   MSG_RETURN(ret);        
 }
 
@@ -164,9 +185,16 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   MSG_error_t ret = MSG_OK;
   simdata_task_t t_simdata = NULL;
   m_process_t process = MSG_process_self();
-  
+#ifdef HAVE_TRACING
+  int call_end = 0;
+#endif
   CHECK_HOST();
 
+#ifdef HAVE_TRACING
+  call_end = TRACE_msg_task_put_start (task); //must be after CHECK_HOST()
+#endif
+
+
   /* Prepare the task to send */
   t_simdata = task->simdata;
   t_simdata->sender = process;
@@ -199,7 +227,7 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
         ret = MSG_TRANSFER_FAILURE;
         break;
       case timeout_error:
-        ret = MSG_TIMEOUT_FAILURE;
+        ret = MSG_TIMEOUT;
         break;
       default:
         xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
@@ -211,6 +239,8 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   }
 
   process->simdata->waiting_task = NULL;
-   
+#ifdef HAVE_TRACING
+  if (call_end) TRACE_msg_task_put_end ();
+#endif
   MSG_RETURN(ret);        
 }