Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / mc / remote / Channel.cpp
index 6eaf30d..43ace95 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2022. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -8,9 +8,10 @@
 #include <xbt/log.h>
 
 #include <cerrno>
-#include <unistd.h>
+#include <cstring>
 #include <sys/socket.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_Channel, mc, "MC interprocess communication");
 
@@ -26,10 +27,12 @@ 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));
+  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;
+    }
   }
   return 0;
 }
@@ -38,7 +41,9 @@ 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", MC_message_type_name(*(e_mc_message_type*)message));
+    XBT_DEBUG("Receive %s", to_c_str(*(MessageType*)message));
+  else
+    XBT_ERROR("Channel::receive failure: %s", strerror(errno));
   return res;
 }
 }