X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/30d28b70caec655b8564a248904b621262de977b..a3427ca7c9f8f2563bb982044e1082cc8f3cdd1e:/src/gras/Transport/transport_plugin_tcp.c diff --git a/src/gras/Transport/transport_plugin_tcp.c b/src/gras/Transport/transport_plugin_tcp.c index 227a4437ab..0d2339602e 100644 --- a/src/gras/Transport/transport_plugin_tcp.c +++ b/src/gras/Transport/transport_plugin_tcp.c @@ -1,6 +1,6 @@ /* $Id$ */ -/* buf trp (transport) - buffered transport using the TCP one */ +/* buf trp (transport) - buffered transport using the TCP one */ /* Copyright (c) 2004 Martin Quinson. All rights reserved. */ @@ -26,7 +26,7 @@ #define MIN(a,b) ((a)<(b)?(a):(b)) #endif -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_tcp,transport, +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_trp_tcp,gras_trp, "TCP buffered transport"); /*** @@ -68,7 +68,7 @@ static inline void gras_trp_sock_socket_client(gras_trp_plugin_t ignored, struct sockaddr_in addr; struct hostent *he; struct in_addr *haddr; - int size = sock->bufSize * 1024; + int size = sock->buf_size; sock->incoming = 1; /* TCP sockets are duplex'ed */ @@ -113,7 +113,7 @@ static inline void gras_trp_sock_socket_client(gras_trp_plugin_t ignored, */ static inline void gras_trp_sock_socket_server(gras_trp_plugin_t ignored, gras_socket_t sock){ - int size = sock->bufSize * 1024; + int size = sock->buf_size; int on = 1; struct sockaddr_in server; @@ -179,8 +179,8 @@ static gras_socket_t gras_trp_sock_socket_accept(gras_socket_t sock) { THROW1(system_error,0,"setsockopt failed, cannot condition the socket: %s", sock_errstr); - res->bufSize = sock->bufSize; - size = sock->bufSize * 1024; + res->buf_size = sock->buf_size; + size = sock->buf_size; if (setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size)) || setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size))) WARN1("setsockopt failed, cannot set buffer size: %s", sock_errstr); @@ -292,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) { @@ -300,13 +300,14 @@ 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; got += status; } else { - THROW0(system_error,0,"Socket closed by remote side"); + THROW1(system_error,0,"Socket closed by remote side (got %d bytes before this)", + got); } } return got; @@ -338,7 +339,7 @@ gras_trp_bufiov_flush(gras_socket_t sock) { DEBUG0("Flush"); if (data->out == buffering_buf) { - if (XBT_LOG_ISENABLED(trp_tcp,xbt_log_priority_debug)) + if (XBT_LOG_ISENABLED(gras_trp_tcp,xbt_log_priority_debug)) hexa_print("chunk to send ", (unsigned char *) data->out_buf.data,data->out_buf.size); if ((data->out_buf.size - data->out_buf.pos) != 0) { @@ -391,14 +392,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); @@ -442,7 +443,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; @@ -564,7 +565,7 @@ gras_socket_t gras_trp_buf_init_sock(gras_socket_t sock) { *** Code ***/ void -gras_trp_buf_setup(gras_trp_plugin_t plug) { +gras_trp_tcp_setup(gras_trp_plugin_t plug) { plug->socket_client = gras_trp_buf_socket_client; plug->socket_server = gras_trp_buf_socket_server;