X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2FAsyncServerSocket.cpp;h=c9f391f08640612a7a01972d4dcb4a066c12ea2d;hp=8a70d77cc188701d60875ee0bde36386f8721fe0;hb=fbc4c23895b0ee3874d9a36401d580a2a8957ba9;hpb=662b86a949f85dfcbf966a346dba8306710eabcb diff --git a/folly/io/async/AsyncServerSocket.cpp b/folly/io/async/AsyncServerSocket.cpp index 8a70d77c..c9f391f0 100644 --- a/folly/io/async/AsyncServerSocket.cpp +++ b/folly/io/async/AsyncServerSocket.cpp @@ -39,6 +39,13 @@ namespace fsp = folly::portability::sockets; namespace folly { +static constexpr bool msgErrQueueSupported = +#ifdef MSG_ERRQUEUE + true; +#else + false; +#endif // MSG_ERRQUEUE + const uint32_t AsyncServerSocket::kDefaultMaxAcceptAtOnce; const uint32_t AsyncServerSocket::kDefaultCallbackAcceptAtOnce; const uint32_t AsyncServerSocket::kDefaultMaxMessagesInQueue; @@ -331,6 +338,18 @@ void AsyncServerSocket::bindSocket( } } +bool AsyncServerSocket::setZeroCopy(bool enable) { + if (msgErrQueueSupported) { + int fd = getSocket(); + int val = enable ? 1 : 0; + int ret = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &val, sizeof(val)); + + return (0 == ret); + } + + return false; +} + void AsyncServerSocket::bind(const SocketAddress& address) { if (eventBase_) { eventBase_->dcheckIsInEventBaseThread();