- /* Associate this simcall to the wait synchro */
- XBT_DEBUG("simcall_HANDLER_comm_wait, %p", comm);
-
- comm->register_simcall(simcall);
-
- if (MC_is_active() || MC_record_replay_is_active()) {
- int idx = simcall->mc_value_;
- if (idx == 0) {
- comm->state_ = simgrid::kernel::activity::State::DONE;
- } else {
- /* If we reached this point, the wait simcall must have a timeout */
- /* Otherwise it shouldn't be enabled and executed by the MC */
- if (timeout < 0.0)
- THROW_IMPOSSIBLE;
-
- if (comm->src_actor_ == simcall->issuer_)
- comm->state_ = simgrid::kernel::activity::State::SRC_TIMEOUT;
- else
- comm->state_ = simgrid::kernel::activity::State::DST_TIMEOUT;
- }
-
- comm->finish();
- return;
- }
-
- /* If the synchro has already finish perform the error handling, */
- /* otherwise set up a waiting timeout on the right side */
- if (comm->state_ != simgrid::kernel::activity::State::WAITING &&
- comm->state_ != simgrid::kernel::activity::State::RUNNING) {
- comm->finish();
- } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
- simgrid::kernel::resource::Action* sleep = simcall->issuer_->get_host()->pimpl_cpu->sleep(timeout);
- sleep->set_activity(comm);
-
- if (simcall->issuer_ == comm->src_actor_)
- comm->src_timeout_ = sleep;
- else
- comm->dst_timeout_ = sleep;
- }