Showing with 7 additions and 2 deletions.
  1. +5 −0 src/unix/stream.c
  2. +2 −2 test/test-tcp-writealot.c
@@ -33,6 +33,7 @@
#include <sys/uio.h>
#include <sys/un.h>
#include <unistd.h>
#include <limits.h> /* IOV_MAX */

#if defined(__APPLE__)
# include <sys/event.h>
@@ -742,6 +743,10 @@ static void uv__write(uv_stream_t* stream) {
iov = (struct iovec*) &(req->bufs[req->write_index]);
iovcnt = req->bufcnt - req->write_index;

/* Limit iov count to avoid EINVALs from writev() */
if (iovcnt > IOV_MAX)
iovcnt = IOV_MAX;

/*
* Now do the actual writev. Note that we've been updating the pointers
* inside the iov each time we write. So there is no need to offset it.
@@ -26,8 +26,8 @@


#define WRITES 3
#define CHUNKS_PER_WRITE 3
#define CHUNK_SIZE 10485760 /* 10 MB */
#define CHUNKS_PER_WRITE 4096
#define CHUNK_SIZE 10024 /* 10 kb */

#define TOTAL_BYTES (WRITES * CHUNKS_PER_WRITE * CHUNK_SIZE)