X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1a64ca4c11a1eb7ba2ecd102f877ac571486a034..5010356b3ded0a463dae327544f6898d57c1e275:/src/mc/remote/Channel.cpp diff --git a/src/mc/remote/Channel.cpp b/src/mc/remote/Channel.cpp index cfbf71565b..1d3c38903c 100644 --- a/src/mc/remote/Channel.cpp +++ b/src/mc/remote/Channel.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2021. The SimGrid Team. +/* Copyright (c) 2015-2023. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -8,14 +8,14 @@ #include #include -#include +#include #include #include +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_Channel, mc, "MC interprocess communication"); -namespace simgrid { -namespace mc { +namespace simgrid::mc { Channel::~Channel() { @@ -26,20 +26,34 @@ Channel::~Channel() /** @brief Send a message; returns 0 on success or errno on failure */ int Channel::send(const void* message, size_t size) const { - XBT_DEBUG("Send %s", to_c_str(*(MessageType*)message)); while (::send(this->socket_, message, size, 0) == -1) { - if (errno != EINTR) + if (errno != EINTR) { + XBT_ERROR("Channel::send failure: %s", strerror(errno)); return errno; + } + } + + if (is_valid_MessageType(*(int*)message)) { + XBT_DEBUG("Sending %s (%lu bytes sent)", to_c_str(*(MessageType*)message), size); + } else { + XBT_DEBUG("Sending bytes directly (from address %p) (%lu bytes sent)", message, size); } + return 0; } ssize_t Channel::receive(void* message, size_t size, bool block) const { ssize_t res = recv(this->socket_, message, size, block ? 0 : MSG_DONTWAIT); - if (res != -1) - XBT_DEBUG("Receive %s", to_c_str(*(MessageType*)message)); + if (res != -1) { + if (is_valid_MessageType(*(int*)message)) { + XBT_DEBUG("Receive %s (requested %lu; received %ld)", to_c_str(*(MessageType*)message), size, res); + } else { + XBT_DEBUG("Receive %ld bytes", res); + } + } else { + XBT_ERROR("Channel::receive failure: %s", strerror(errno)); + } return res; } -} -} +} // namespace simgrid::mc