X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/24eff0b164b2560dd2a6237573213fbc944cde64..8d0b1f2f1840a16bb9551f1cfd74f2488599f95b:/src/kernel/activity/CommImpl.cpp?ds=inline diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index ad1c7fe676..f264993204 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -20,13 +20,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_network, kernel, "Kernel network-related synchronization"); namespace simgrid::kernel::activity { -xbt::signal CommImpl::on_start; -xbt::signal CommImpl::on_completion; + +unsigned CommImpl::next_id_ = 0; std::function CommImpl::copy_data_callback_ = [](kernel::activity::CommImpl* comm, void* buff, size_t buff_size) { xbt_assert((buff_size == sizeof(void*)), "Cannot copy %zu bytes: must be sizeof(void*)", buff_size); - *(void**)(comm->dst_buff_) = buff; + if (comm->dst_buff_ != nullptr) // get_async provided a buffer + *(void**)(comm->dst_buff_) = buff; + comm->payload_ = buff; // Setup what will be retrieved by s4u::Comm::get_payload() }; void CommImpl::set_copy_data_callback(const std::function& callback) @@ -166,7 +168,7 @@ CommImpl* CommImpl::start() std::vector CommImpl::get_traversed_links() const { - xbt_assert(get_state() != State::WAITING, "You cannot use %s() if your communication is not ready (%s)", __FUNCTION__, + xbt_assert(get_state() != State::WAITING, "You cannot use %s() if your communication is not ready (%s)", __func__, get_state_str()); std::vector vlinks; XBT_ATTRIB_UNUSED double res = 0; @@ -179,7 +181,7 @@ void CommImpl::copy_data() { size_t buff_size = src_buff_size_; /* If there is no data to copy then return */ - if (not src_buff_ || not dst_buff_ || copied_) + if (not src_buff_ || not dst_buff_size_ || copied_) return; XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)", this, @@ -470,9 +472,12 @@ void CommImpl::finish() XBT_DEBUG("CommImpl::finish() comm %p, state %s, src_proc %p, dst_proc %p, detached: %d", this, get_state_str(), src_actor_.get(), dst_actor_.get(), detached_); - auto* piface = static_cast(this->get_iface()); - s4u::Comm::on_completion(*piface); - piface->on_this_completion(*piface); + if (get_iface()) { + const auto& piface = static_cast(*get_iface()); + set_iface(nullptr); // reset iface to protect against multiple trigger of the on_completion signals + piface.fire_on_completion_for_real(); + piface.fire_on_this_completion_for_real(); + } /* Update synchro state */ if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FINISHED)