Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
typos and reduce debug verbosity
[simgrid.git] / src / gras / Transport / rl_transport.c
index 3bebb3e..f142dfc 100644 (file)
@@ -7,12 +7,14 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/ex.h"
+#include "xbt/xbt_socket_private.h" /* FIXME */
 #include "portable.h"
 #include "gras/Transport/transport_private.h"
+
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(gras_trp);
 
 /* check transport_private.h for an explanation of this variable */
-gras_socket_t _gras_lastly_selected_socket = NULL;
+xbt_socket_t _gras_lastly_selected_socket = NULL;
 
 /**
  * gras_trp_select:
@@ -24,7 +26,7 @@ gras_socket_t _gras_lastly_selected_socket = NULL;
  *
  * if timeout>0 and no message there, wait at most that amount of time before giving up.
  */
-gras_socket_t gras_trp_select(double timeout)
+xbt_socket_t gras_trp_select(double timeout)
 {
   xbt_dynar_t sockets =
       ((gras_trp_procdata_t)
@@ -43,7 +45,7 @@ gras_socket_t gras_trp_select(double timeout)
   int ready;                    /* return of select: number of socket ready to be serviced */
   static int fd_setsize = -1;   /* FD_SETSIZE not always defined. Get this portably */
 
-  gras_socket_t sock_iter;      /* iterating over all sockets */
+  xbt_socket_t sock_iter;      /* iterating over all sockets */
   unsigned int cursor;          /* iterating over all sockets */
 
   /* Check whether there is more data to read from the socket we selected last time.
@@ -74,8 +76,8 @@ gras_socket_t gras_trp_select(double timeout)
       XBT_DEBUG("wakeup=%f now=%f", wakeup, now);
       if (now == -1 || now >= wakeup) {
         /* didn't find anything; no need to update _gras_lastly_selected_socket since its moredata is 0 (or we would have returned it directly) */
-        THROW1(timeout_error, 0,
-               "Timeout (%f) elapsed with selecting for incomming connexions",
+        THROWF(timeout_error, 0,
+               "Timeout (%f) elapsed with selecting for incoming connections",
                timeout);
       }
     }
@@ -88,7 +90,7 @@ gras_socket_t gras_trp_select(double timeout)
         continue;
 
       if (sock_iter->incoming) {
-        XBT_DEBUG("Considering socket %d for select", sock_iter->sd);
+        //XBT_DEBUG("Considering socket %d for select", sock_iter->sd);
 #ifndef HAVE_WINSOCK_H
         if (max_fds < sock_iter->sd)
           max_fds = sock_iter->sd;
@@ -107,11 +109,11 @@ gras_socket_t gras_trp_select(double timeout)
       if (timeout > 0) {
         XBT_DEBUG("No socket to select onto. Sleep %f sec instead.", timeout);
         gras_os_sleep(timeout);
-        THROW1(timeout_error, 0,
+        THROWF(timeout_error, 0,
                "No socket to select onto. Sleep %f sec instead", timeout);
       } else {
         XBT_DEBUG("No socket to select onto. Return directly.");
-        THROW0(timeout_error, 0,
+        THROWF(timeout_error, 0,
                "No socket to select onto. Return directly.");
       }
     }
@@ -156,13 +158,13 @@ gras_socket_t gras_trp_select(double timeout)
         /* if we cared, we would have set an handler */
         continue;
       case EINVAL:             /* invalid value */
-        THROW3(system_error, EINVAL,
+        THROWF(system_error, EINVAL,
                "invalid select: nb fds: %d, timeout: %d.%d", max_fds,
                (int) tout.tv_sec, (int) tout.tv_usec);
       case ENOMEM:
         xbt_die("Malloc error during the select");
       default:
-        THROW2(system_error, errno, "Error during select: %s (%d)",
+        THROWF(system_error, errno, "Error during select: %s (%d)",
                strerror(errno), errno);
       }
       THROW_IMPOSSIBLE;
@@ -180,7 +182,7 @@ gras_socket_t gras_trp_select(double timeout)
 
       if (sock_iter->accepting && sock_iter->plugin->socket_accept) {
         /* not a socket but an ear. accept on it and serve next socket */
-        gras_socket_t accepted = NULL;
+        xbt_socket_t accepted = NULL;
 
         /* release mutex before accept; it will change the sockets dynar, so we have to break the foreach asap */
         xbt_dynar_cursor_unlock(sockets);
@@ -213,7 +215,7 @@ gras_socket_t gras_trp_select(double timeout)
           sock_iter->valid = 0; /* don't close it. User may keep references to it */
         } else {
           /* Got a suited socket ! */
-          XBT_OUT;
+          XBT_OUT();
           sock_iter->recvd = 1;
           XBT_DEBUG("Filled little buffer (%c %x %d)", sock_iter->recvd_val,
                  sock_iter->recvd_val, recvd);
@@ -236,10 +238,11 @@ gras_socket_t gras_trp_select(double timeout)
 
   /* No socket found. Maybe we had timeout=0 and nothing to do */
   XBT_DEBUG("TIMEOUT");
-  THROW0(timeout_error, 0, "Timeout");
+  THROWF(timeout_error, 0, "Timeout");
 }
 
-void gras_trp_sg_setup(gras_trp_plugin_t plug)
+/* to make the linker happy in SG mode */
+void gras_trp_sg_setup(xbt_trp_plugin_t plug)
 {
-  THROW0(mismatch_error, 0, "No SG transport on live platforms");
+  THROWF(mismatch_error, 0, "No SG transport on live platforms");
 }