- case SIMIX_DONE:
- /* do nothing, synchro done */
- XBT_DEBUG("ExecImpl::finish(): execution successful");
- break;
-
- case SIMIX_FAILED:
- XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer->get_host()->get_cname());
- simcall->issuer->context_->iwannadie = true;
- if (simcall->issuer->get_host()->is_on())
- simcall->issuer->exception_ =
- std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
- /* else, the actor will be killed with no possibility to survive */
+ /* If a waitany simcall is waiting for this synchro to finish, then remove it from the other synchros in the waitany
+ * list. Afterwards, get the position of the actual synchro in the waitany list and return it as the result of the
+ * simcall */
+
+ if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
+ continue; // if process handling comm is killed
+ if (auto* observer =
+ dynamic_cast<kernel::actor::ExecutionWaitanySimcall*>(simcall->observer_)) { // simcall is a wait_any?
+ const auto& execs = observer->get_execs();
+
+ for (auto* exec : execs) {
+ exec->unregister_simcall(simcall);
+
+ if (simcall->timeout_cb_) {
+ simcall->timeout_cb_->remove();
+ simcall->timeout_cb_ = nullptr;
+ }
+ }
+
+ if (not MC_is_active() && not MC_record_replay_is_active()) {
+ auto element = std::find(execs.begin(), execs.end(), this);
+ int rank = element != execs.end() ? static_cast<int>(std::distance(execs.begin(), element)) : -1;
+ observer->set_result(rank);
+ }
+ }
+ switch (state_) {
+ case State::FAILED:
+ piface_->complete(s4u::Activity::State::FAILED);
+ if (simcall->issuer_->get_host()->is_on())
+ simcall->issuer_->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
+ else /* else, the actor will be killed with no possibility to survive */
+ simcall->issuer_->context_->set_wannadie();