-
- DEBUG4("Trying to send a task (%g kB) from %s to %s on the channel %s",
- t_simdata->message_size / 1000, local_host->name,
- remote_host->name, MSG_mailbox_get_alias(mailbox));
-
- SIMIX_mutex_lock(remote_host->simdata->mutex);
-
- /* put the task in the mailbox */
- xbt_fifo_push(mailbox->tasks, task);
-
- if ((cond = MSG_mailbox_get_cond(mailbox))) {
- DEBUG0("Somebody is listening. Let's wake him up!");
- SIMIX_cond_signal(cond);
- }
-
- SIMIX_mutex_unlock(remote_host->simdata->mutex);
-
- SIMIX_mutex_lock(t_simdata->mutex);
-
- process->simdata->waiting_task = task;
-
- if (timeout > 0) {
- xbt_ex_t e;
- double time;
- double time_elapsed;
- time = SIMIX_get_clock();
-
- TRY {
- /*verify if the action that ends is the correct. Call the wait_timeout with the new time. If the timeout occurs, an exception is raised */
- while (1) {
- time_elapsed = SIMIX_get_clock() - time;
- SIMIX_cond_wait_timeout(t_simdata->cond, t_simdata->mutex,
- timeout - time_elapsed);
-
- if ((t_simdata->comm != NULL)
- && (SIMIX_action_get_state(t_simdata->comm) !=
- SURF_ACTION_RUNNING))
- break;
- if (!SIMIX_host_get_state(local_host->simdata->smx_host))
- break;
- if (!SIMIX_host_get_state(remote_host->simdata->smx_host))
- break;
- }
- }
- CATCH(e) {
- if (e.category == timeout_error) {
- xbt_ex_free(e);
- /* verify if the timeout happened and the communication didn't started yet */
- if (t_simdata->comm == NULL) {
- process->simdata->waiting_task = NULL;
-
- /* remove the task from the mailbox */
- MSG_mailbox_remove(mailbox, task);
-
- if (t_simdata->receiver && t_simdata->receiver->simdata) { /* receiver still around */
- t_simdata->receiver->simdata->waiting_task = NULL;
- }
-
- SIMIX_mutex_unlock(t_simdata->mutex);
- MSG_RETURN(MSG_TRANSFER_FAILURE);
- }
- } else {
- RETHROW;
- }
- }
- } else {
- while (1) {
- SIMIX_cond_wait(t_simdata->cond, t_simdata->mutex);
-
- if (SIMIX_action_get_state(t_simdata->comm) != SURF_ACTION_RUNNING)
- break;
- if (!SIMIX_host_get_state(local_host->simdata->smx_host))
- break;
- if (!SIMIX_host_get_state(remote_host->simdata->smx_host))
- break;
+ /* Try to send it by calling SIMIX network layer */
+ TRY {
+#ifdef HAVE_TRACING
+ 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