X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/96cedde3cdbc0b8ffc3f096a1b65d021b0226f99..64de47b20e85d84061588859bbae0212bb59ccfe:/src/mc/remote/Channel.cpp diff --git a/src/mc/remote/Channel.cpp b/src/mc/remote/Channel.cpp index 7594e5e68b..dfd07e5fe1 100644 --- a/src/mc/remote/Channel.cpp +++ b/src/mc/remote/Channel.cpp @@ -1,23 +1,21 @@ -/* Copyright (c) 2015-2019. 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 * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include +#include "src/mc/remote/Channel.hpp" +#include +#include +#include #include #include - -#include - -#include "src/mc/remote/Channel.hpp" +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_Channel, mc, "MC interprocess communication"); -namespace simgrid { -namespace mc { +namespace simgrid::mc { Channel::~Channel() { @@ -28,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", MC_message_type_name(*(e_mc_message_type*)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(*static_cast(message))) { + XBT_DEBUG("Sending %s (%zu bytes sent)", to_c_str(*static_cast(message)), size); + } else { + XBT_DEBUG("Sending bytes directly (from address %p) (%zu bytes sent)", message, size); } + return 0; } ssize_t Channel::receive(void* message, size_t size, bool block) const { - int res = recv(this->socket_, message, size, block ? 0 : MSG_DONTWAIT); - if (res != -1) - XBT_DEBUG("Receive %s", MC_message_type_name(*(e_mc_message_type*)message)); + ssize_t res = recv(this->socket_, message, size, block ? 0 : MSG_DONTWAIT); + if (res != -1) { + if (is_valid_MessageType(*static_cast(message))) { + XBT_DEBUG("Receive %s (requested %zu; received %zd)", to_c_str(*static_cast(message)), size, res); + } else { + XBT_DEBUG("Receive %zd bytes", res); + } + } else { + XBT_ERROR("Channel::receive failure: %s", strerror(errno)); + } return res; } -} -} +} // namespace simgrid::mc