Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a few casts to help compilation with gcc-4.0
[simgrid.git] / src / gras / Transport / transport_plugin_tcp.c
index d8bc067..ca4b880 100644 (file)
@@ -16,6 +16,8 @@
 #include "xbt/ex.h"
 #include "transport_private.h"
 
+#undef HAVE_READV
+
 #ifdef HAVE_READV
 #include <sys/uio.h>
 #endif       
@@ -290,7 +292,7 @@ gras_trp_tcp_recv_withbuffer(gras_socket_t sock,
     
     DEBUG5("read(%d, %p, %ld) got %d so far (%s)",
          sock->sd, data+got, bufsize, got,
-         hexa_str(data,got));
+         hexa_str((unsigned char*)data,got));
     status = tcp_read(sock->sd, data+got, (size_t)bufsize);
     
     if (status < 0) {
@@ -298,7 +300,7 @@ gras_trp_tcp_recv_withbuffer(gras_socket_t sock,
             sock->sd, data+got, (int)size,
             sock_errstr);
     }
-    DEBUG2("Got %d more bytes (%s)",status,hexa_str(data+got,status));
+    DEBUG2("Got %d more bytes (%s)",status,hexa_str((unsigned char*)data+got,status));
     
     if (status) {
       bufsize -= status;
@@ -350,6 +352,7 @@ gras_trp_bufiov_flush(gras_socket_t sock) {
 
 #ifdef HAVE_READV
   if (data->out == buffering_iov) {
+    DEBUG0("Flush out iov");
     vect = sock->bufdata->out_buf_v;
     if ((size = xbt_dynar_length(vect))) {
       DEBUG1("Flush %d chunks out of this socket",size);
@@ -360,6 +363,7 @@ gras_trp_bufiov_flush(gras_socket_t sock) {
   }
 
   if (data->in == buffering_iov) {
+    DEBUG0("Flush in iov");
     vect = sock->bufdata->in_buf_v;
     if ((size = xbt_dynar_length(vect))) {
       DEBUG1("Get %d chunks from of this socket",size);
@@ -387,14 +391,14 @@ gras_trp_buf_send(gras_socket_t sock,
           (int)data->out_buf.size,
           ((int)data->out_buf.size) + thissize -1,
           size,
-          hexa_str((char*)chunk,thissize));
+          hexa_str((unsigned char*)chunk,thissize));
 
     memcpy(data->out_buf.data + data->out_buf.size, chunk + chunk_pos, thissize);
 
     data->out_buf.size += thissize;
     chunk_pos      += thissize;
     DEBUG4("New pos = %d; Still to send = %ld of %ld; ctn sofar=(%s)",
-          data->out_buf.size,size-chunk_pos,size,hexa_str((char*)chunk,chunk_pos));
+          data->out_buf.size,size-chunk_pos,size,hexa_str((unsigned char*)chunk,chunk_pos));
 
     if (data->out_buf.size == data->buffsize) /* out of space. Flush it */
       gras_trp_bufiov_flush(sock);
@@ -438,7 +442,7 @@ gras_trp_buf_recv(gras_socket_t sock,
     data->in_buf.pos += thissize;
     chunk_pos        += thissize;
     DEBUG4("New pos = %d; Still to receive = %ld of %ld. Ctn so far=(%s)",
-          data->in_buf.pos,size - chunk_pos,size,hexa_str(chunk,chunk_pos));
+          data->in_buf.pos,size - chunk_pos,size,hexa_str((unsigned char*)chunk,chunk_pos));
   }
 
   XBT_OUT;
@@ -541,15 +545,16 @@ gras_socket_t gras_trp_buf_init_sock(gras_socket_t sock) {
   data->out_buf.data = xbt_malloc(data->buffsize);
   data->out_buf.pos  = data->out_buf.size;
 
-  data->in_buf_v = data->out_buf_v = NULL;
 #ifdef HAVE_READV
+  data->in_buf_v = data->out_buf_v = NULL;
   data->in_buf_v=xbt_dynar_new(sizeof(struct iovec),NULL);
   data->out_buf_v=xbt_dynar_new(sizeof(struct iovec),NULL);
+  data->out = buffering_iov;
+#else
+  data->out = buffering_buf;
 #endif
    
   data->in = buffering_buf;
-  data->out = buffering_iov;
-  /*data->out = buffering_buf;*/
 
   sock->bufdata = data;
   return sock;
@@ -566,8 +571,11 @@ gras_trp_buf_setup(gras_trp_plugin_t plug) {
   plug->socket_accept = gras_trp_buf_socket_accept;
   plug->socket_close  = gras_trp_buf_socket_close;
 
+#ifdef HAVE_READV
   plug->send = gras_trp_iov_send;
-  /*plug->send = gras_trp_buf_send;*/
+#else
+  plug->send = gras_trp_buf_send;
+#endif
   plug->recv = gras_trp_buf_recv;
 
   plug->raw_send    = gras_trp_tcp_send;