Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Renamed any gras stuff that was in xbt and should therefore be called
[simgrid.git] / src / gras / Transport / rl_transport.c
index ce85e46..bd697f1 100644 (file)
@@ -9,12 +9,13 @@
    under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <errno.h>
+#include <sys/time.h> /* struct timeval */
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include "Transport/transport_private.h"
-GRAS_LOG_EXTERNAL_CATEGORY(transport);
-GRAS_LOG_DEFAULT_CATEGORY(transport);
+#include "gras/Transport/transport_private.h"
+XBT_LOG_EXTERNAL_CATEGORY(transport);
+XBT_LOG_DEFAULT_CATEGORY(transport);
 
 
 
@@ -29,30 +30,30 @@ GRAS_LOG_DEFAULT_CATEGORY(transport);
  *
  * if timeout>0 and no message there, wait at most that amount of time before giving up.
  */
-gras_error_t 
+xbt_error_t 
 gras_trp_select(double timeout,
-               gras_socket_t **dst) {
+               gras_socket_t *dst) {
 
-  gras_error_t errcode;
-  gras_dynar_t *sockets= gras_socketset_get();
+  xbt_error_t errcode;
+  xbt_dynar_t sockets= gras_socketset_get();
   int done = -1;
-  double wakeup = gras_time() + 1000000*timeout;
+  double wakeup = gras_os_time() + 1000000*timeout;
   double now = 0;
   /* nextToService used to make sure socket with high number do not starve */
-  //  static int nextToService = 0;
+  /*  static int nextToService = 0; */
   struct timeval tout, *p_tout;
 
   int max_fds=0; /* first arg of select: number of existing sockets */
   fd_set FDS;
   int ready; /* return of select: number of socket ready to be serviced */
 
-  gras_socket_t *sock_iter; /* iterating over all sockets */
-  int cursor;               /* iterating over all sockets */
+  gras_socket_t sock_iter; /* iterating over all sockets */
+  int cursor;              /* iterating over all sockets */
 
   *dst=NULL;
   while (done == -1) {
     if (timeout > 0) { /* did we timeout already? */
-      now = gras_time();
+      now = gras_os_time();
       if (now == -1 || now >= wakeup) {
        done = 0;       /* didn't find anything */
        break;
@@ -61,7 +62,7 @@ gras_trp_select(double timeout,
 
     /* construct the set of socket to ear from */
     FD_ZERO(&FDS);
-    gras_dynar_foreach(sockets,cursor,sock_iter) {
+    xbt_dynar_foreach(sockets,cursor,sock_iter) {
       if (sock_iter->incoming) {
        if (max_fds < sock_iter->sd)
          max_fds = sock_iter->sd;
@@ -106,7 +107,7 @@ gras_trp_select(double timeout,
        RAISE3(system_error,"invalid select: nb fds: %d, timeout: %d.%d",
               max_fds, (int)tout.tv_sec,(int) tout.tv_usec);
       case ENOMEM: 
-       RAISE_MALLOC;
+       xbt_assert0(0,"Malloc error during the select");
       default:
        RAISE2(system_error,"Error during select: %s (%d)",
               strerror(errno),errno);
@@ -116,7 +117,7 @@ gras_trp_select(double timeout,
       continue;         /* this was a timeout */
     }
 
-    gras_dynar_foreach(sockets,cursor,sock_iter) { 
+    xbt_dynar_foreach(sockets,cursor,sock_iter) { 
        if(!FD_ISSET(sock_iter->sd, &FDS)) { /* this socket is not ready */
        continue;
        }
@@ -127,11 +128,10 @@ 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;
+        gras_socket_t accepted;
 
         TRY(sock_iter->plugin->socket_accept(sock_iter,&accepted));
         accepted->raw = sock_iter->raw;
-        TRY(gras_dynar_push(sockets,&accepted));
        } else {
 #if 0 
        FIXME: this fails of files. quite logical
@@ -171,6 +171,6 @@ gras_trp_select(double timeout,
   return timeout_error;
 }
 
-gras_error_t gras_trp_sg_setup(gras_trp_plugin_t *plug) {
+xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t *plug) {
   return mismatch_error;
 }