From: mquinson Date: Fri, 4 Mar 2005 11:37:31 +0000 (+0000) Subject: - Bugfix: flush the socket on close only if there is some *output*. X-Git-Tag: v3.3~4206 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/44039849440cb2435ccb956c06b82ac4ee1b8ee6 - Bugfix: flush the socket on close only if there is some *output*. - Bugfix: flush idempotent when there's nothing to send (don't send size=0) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1147 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/gras/Transport/transport_plugin_buf.c b/src/gras/Transport/transport_plugin_buf.c index 5294c51763..bbfe9dda12 100644 --- a/src/gras/Transport/transport_plugin_buf.c +++ b/src/gras/Transport/transport_plugin_buf.c @@ -160,8 +160,15 @@ void gras_trp_buf_socket_close(gras_socket_t sock){ gras_trp_bufdata_t *data=sock->bufdata; XBT_IN; - if (data->in.size || data->out.size) + if (data->in.size!=data->in.pos) { + WARN1("Socket closed, but %d bytes were unread",data->in.size - data->in.pos); + } + + if (data->out.size!=data->out.pos) { + DEBUG2("Flush the socket before closing (in=%d,out=%d)",data->in.size, data->out.size); gras_trp_buf_flush(sock); + } + if (data->in.data) free(data->in.data); if (data->out.data) @@ -277,8 +284,13 @@ gras_trp_buf_flush(gras_socket_t sock) { gras_trp_bufdata_t *data=sock->bufdata; XBT_IN; - size = (int)htonl(data->out.size); - DEBUG1("Send the size (=%d)",data->out.size); + if (! (data->out.size-data->out.pos) ) { + DEBUG0("Nothing to flush"); + return no_error; + } + + size = (int)htonl(data->out.size-data->out.pos); + DEBUG1("Send the size (=%d)",data->out.size-data->out.pos); TRY(super->chunk_send(sock,(char*) &size, 4)); DEBUG1("Send the chunk (size=%d)",data->out.size);