Commit 1d8e5b67 authored by Kenton Varda's avatar Kenton Varda

Apparently writev() imposes a limit on the vector size. Work around that. Not…

Apparently writev() imposes a limit on the vector size.  Work around that.  Not sure why libc doesn't already do this.
parent 6afedf8c
......@@ -279,6 +279,17 @@ void FdOutputStream::write(const void* buffer, size_t size) {
}
void FdOutputStream::write(ArrayPtr<const ArrayPtr<const byte>> pieces) {
// Apparently, there is a maximum number of iovecs allowed per call. I don't understand why.
// Also, most platforms define IOV_MAX but Linux defines only UIO_MAXIOV. Unfortunately, Solaris
// defines a constant UIO_MAXIOV with a different meaning, so we check for IOV_MAX first.
#if !defined(IOV_MAX) && defined(UIO_MAXIOV)
#define IOV_MAX UIO_MAXIOV
#endif
while (pieces.size() > IOV_MAX) {
write(pieces.slice(0, IOV_MAX));
pieces = pieces.slice(IOV_MAX, pieces.size());
}
KJ_STACK_ARRAY(struct iovec, iov, pieces.size(), 16, 128);
for (uint i = 0; i < pieces.size(); i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment