-void gras_trp_tcp_socket_close(gras_socket_t sock){
- gras_trp_tcp_plug_data_t *tcp;
-
- if (!sock) return; /* close only once */
- tcp=sock->plugin->data;
-
- DEBUG1("close tcp connection %d", sock->sd);
-
- /* FIXME: no pipe in GRAS so far
- if(!FD_ISSET(sd, &connectedPipes)) {
- if(shutdown(sd, 2) < 0) {
- GetNWSLock(&lock);
- tmp_errno = errno;
- ReleaseNWSLock(&lock);
-
- / * The other side may have beaten us to the reset. * /
- if ((tmp_errno!=ENOTCONN) && (tmp_errno!=ECONNRESET)) {
- WARN1("CloseSocket: shutdown error %d\n", tmp_errno);
- }
+/*******************************************/
+/****[ end of UNBUFFERED DATA EXCHANGE ]****/
+/*******************************************/
+
+/**********************************/
+/****[ BUFFERED DATA EXCHANGE ]****/
+/**********************************/
+
+/* Make sure the data is sent */
+static void gras_trp_bufiov_flush(gras_socket_t sock)
+{
+#ifdef HAVE_READV
+ xbt_dynar_t vect;
+ int size;
+#endif
+ gras_trp_bufdata_t *data = sock->bufdata;
+ XBT_IN("");
+
+ XBT_DEBUG("Flush");
+ if (data->out == buffering_buf) {
+ 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) {
+ XBT_DEBUG("Send the chunk (size=%d) to %s:%d", data->out_buf.size,
+ gras_socket_peer_name(sock), gras_socket_peer_port(sock));
+ gras_trp_tcp_send(sock, data->out_buf.data, data->out_buf.size);
+ XBT_VERB("Chunk sent (size=%d)", data->out_buf.size);
+ data->out_buf.size = 0;
+ }
+ }
+#ifdef HAVE_READV
+ if (data->out == buffering_iov) {
+ XBT_DEBUG("Flush out iov");
+ vect = sock->bufdata->out_buf_v;
+ if ((size = xbt_dynar_length(vect))) {
+ XBT_DEBUG("Flush %d chunks out of this socket", size);
+ writev(sock->sd, xbt_dynar_get_ptr(vect, 0), size);
+ xbt_dynar_reset(vect);
+ }
+ data->out_buf.size = 0; /* reset the buffer containing non-stable data */
+ }
+
+ if (data->in == buffering_iov) {
+ XBT_DEBUG("Flush in iov");
+ vect = sock->bufdata->in_buf_v;
+ if ((size = xbt_dynar_length(vect))) {
+ XBT_DEBUG("Get %d chunks from of this socket", size);
+ readv(sock->sd, xbt_dynar_get_ptr(vect, 0), size);
+ xbt_dynar_reset(vect);