Commit 8f7fb4fb authored by Michael Lee's avatar Michael Lee Committed by facebook-github-bot-1

Handle wrapvFull when IOV_MAX is not defined.

Summary:--Perhaps this should move to Portability.h instead.  There is another instance of this in io/async/AsyncSocket.cpp.--

Added `portability/SysUio.h` to handle the c-macro conversion into a usable value.

Reviewed By: yfeldblum

Differential Revision: D2940778

fb-gh-sync-id: 897e44b430c02e5a7d826f3e8da9e4979b7b898c
shipit-source-id: 897e44b430c02e5a7d826f3e8da9e4979b7b898c
parent 167e2483
......@@ -263,6 +263,7 @@ nobase_follyinclude_HEADERS = \
PicoSpinLock.h \
Portability.h \
portability/Syscall.h \
portability/SysUio.h \
ConditionallyExistent.h \
Preprocessor.h \
ProducerConsumerQueue.h \
......
......@@ -20,7 +20,7 @@
#include <cerrno>
#include <unistd.h>
#include <sys/uio.h>
#include <folly/portability/SysUio.h>
/**
* Helper functions and templates for FileUtil.cpp. Declared here so
......@@ -76,7 +76,7 @@ ssize_t wrapvFull(F f, int fd, iovec* iov, int count, Offset... offset) {
ssize_t totalBytes = 0;
size_t r;
do {
r = f(fd, iov, std::min(count, IOV_MAX), offset...);
r = f(fd, iov, std::min<int>(count, kIovMax), offset...);
if (r == (size_t)-1) {
if (errno == EINTR) {
continue;
......
......@@ -20,6 +20,7 @@
#include <folly/io/async/EventHandler.h>
#include <folly/SocketAddress.h>
#include <folly/io/IOBuf.h>
#include <folly/portability/SysUio.h>
#include <poll.h>
#include <errno.h>
......@@ -1711,11 +1712,7 @@ ssize_t AsyncSocket::performWrite(const iovec* vec,
msg.msg_name = nullptr;
msg.msg_namelen = 0;
msg.msg_iov = const_cast<iovec *>(vec);
#ifdef IOV_MAX // not defined on Android
msg.msg_iovlen = std::min(count, (uint32_t)IOV_MAX);
#else
msg.msg_iovlen = std::min(count, (uint32_t)UIO_MAXIOV);
#endif
msg.msg_iovlen = std::min<size_t>(count, kIovMax);
msg.msg_control = nullptr;
msg.msg_controllen = 0;
msg.msg_flags = 0;
......
/*
* Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOLLY_SYSUIO_H_
#define FOLLY_SYSUIO_H_
#include <sys/uio.h>
namespace folly {
#ifdef IOV_MAX // not defined on Android
constexpr size_t kIovMax = IOV_MAX;
#else
constexpr size_t kIovMax = UIO_MAXIOV;
#endif
}
#endif
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