X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/63c371bbca5afccc4708761d83af6fc2443ca553..51944fbb208aeba94040ac47118d748f2cb5c854:/src/mc/remote/Channel.cpp diff --git a/src/mc/remote/Channel.cpp b/src/mc/remote/Channel.cpp index 30ccdcd74e..6eaf30da05 100644 --- a/src/mc/remote/Channel.cpp +++ b/src/mc/remote/Channel.cpp @@ -1,19 +1,17 @@ -/* Copyright (c) 2015-2016. The SimGrid Team. +/* Copyright (c) 2015-2019. 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" - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_Channel, mc, "MC interprocess communication"); namespace simgrid { @@ -25,20 +23,20 @@ Channel::~Channel() close(this->socket_); } +/** @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) - continue; - else + while (::send(this->socket_, message, size, 0) == -1) { + if (errno != EINTR) return errno; + } 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); + ssize_t 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)); return res;