From 760b0714e995578b392bb50eb40eaa032f255631 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 26 Oct 2017 12:14:23 -0700 Subject: [PATCH] Fix build with Windows SDK v10.0.16232 Summary: It defines `MSG_ERRQUEUE` which breaks things. There's a github PR to do this in a different way, but it's faster to just do it myself. Closes https://github.com/facebook/folly/pull/689 Reviewed By: yfeldblum Differential Revision: D6155606 fbshipit-source-id: f1c6b247efc452b4005ad3b6d82fabfd5a92f49f --- folly/io/async/AsyncServerSocket.cpp | 4 ++-- folly/io/async/AsyncSocket.cpp | 12 ++++++------ folly/io/async/test/AsyncSSLSocketTest.cpp | 6 +++--- folly/io/async/test/AsyncSSLSocketTest.h | 4 ++-- folly/io/async/test/AsyncSocketTest2.cpp | 4 ++-- folly/portability/Sockets.h | 1 + 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/folly/io/async/AsyncServerSocket.cpp b/folly/io/async/AsyncServerSocket.cpp index 908a95b6..19bc823f 100644 --- a/folly/io/async/AsyncServerSocket.cpp +++ b/folly/io/async/AsyncServerSocket.cpp @@ -40,11 +40,11 @@ namespace fsp = folly::portability::sockets; namespace folly { static constexpr bool msgErrQueueSupported = -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE true; #else false; -#endif // MSG_ERRQUEUE +#endif // FOLLY_HAVE_MSG_ERRQUEUE const uint32_t AsyncServerSocket::kDefaultMaxAcceptAtOnce; const uint32_t AsyncServerSocket::kDefaultCallbackAcceptAtOnce; diff --git a/folly/io/async/AsyncSocket.cpp b/folly/io/async/AsyncSocket.cpp index b8349687..a4c41969 100644 --- a/folly/io/async/AsyncSocket.cpp +++ b/folly/io/async/AsyncSocket.cpp @@ -42,11 +42,11 @@ namespace fsp = folly::portability::sockets; namespace folly { static constexpr bool msgErrQueueSupported = -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE true; #else false; -#endif // MSG_ERRQUEUE +#endif // FOLLY_HAVE_MSG_ERRQUEUE // static members initializers const AsyncSocket::OptionMap AsyncSocket::emptyOptionMap; @@ -933,7 +933,7 @@ bool AsyncSocket::containsZeroCopyBuf(folly::IOBuf* ptr) { } bool AsyncSocket::isZeroCopyMsg(const cmsghdr& cmsg) const { -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE if (zeroCopyEnabled_ && ((cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR) || (cmsg.cmsg_level == SOL_IPV6 && cmsg.cmsg_type == IPV6_RECVERR))) { @@ -947,7 +947,7 @@ bool AsyncSocket::isZeroCopyMsg(const cmsghdr& cmsg) const { } void AsyncSocket::processZeroCopyMsg(const cmsghdr& cmsg) { -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE const struct sock_extended_err* serr = reinterpret_cast(CMSG_DATA(&cmsg)); uint32_t hi = serr->ee_data; @@ -1761,7 +1761,7 @@ void AsyncSocket::handleErrMessages() noexcept { return; } -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE uint8_t ctrl[1024]; unsigned char data; struct msghdr msg; @@ -1808,7 +1808,7 @@ void AsyncSocket::handleErrMessages() noexcept { } } } -#endif //MSG_ERRQUEUE +#endif // FOLLY_HAVE_MSG_ERRQUEUE } void AsyncSocket::handleRead() noexcept { diff --git a/folly/io/async/test/AsyncSSLSocketTest.cpp b/folly/io/async/test/AsyncSSLSocketTest.cpp index 10e52110..6268848b 100644 --- a/folly/io/async/test/AsyncSSLSocketTest.cpp +++ b/folly/io/async/test/AsyncSSLSocketTest.cpp @@ -37,7 +37,7 @@ #include #include -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE #include #endif @@ -2189,7 +2189,7 @@ TEST(AsyncSSLSocketTest, SendMsgParamsCallback) { cerr << "SendMsgParamsCallback test completed" << endl; } -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE /** * Test connecting to, writing to, reading from, and closing the * connection to the SSL server. @@ -2263,7 +2263,7 @@ TEST(AsyncSSLSocketTest, SendMsgDataCallback) { cerr << "SendMsgDataCallback test completed" << endl; } -#endif // MSG_ERRQUEUE +#endif // FOLLY_HAVE_MSG_ERRQUEUE #endif diff --git a/folly/io/async/test/AsyncSSLSocketTest.h b/folly/io/async/test/AsyncSSLSocketTest.h index 0ee12873..3768aee7 100644 --- a/folly/io/async/test/AsyncSSLSocketTest.h +++ b/folly/io/async/test/AsyncSSLSocketTest.h @@ -186,7 +186,7 @@ public WriteCallbackBase { } }; -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE /* copied from include/uapi/linux/net_tstamp.h */ /* SO_TIMESTAMPING gets an integer bit field comprised of these values */ enum SOF_TIMESTAMPING { @@ -276,7 +276,7 @@ class WriteCheckTimestampCallback : bool gotTimestamp_{false}; bool gotByteSeq_{false}; }; -#endif // MSG_ERRQUEUE +#endif // FOLLY_HAVE_MSG_ERRQUEUE class ReadCallbackBase : public AsyncTransportWrapper::ReadCallback { diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index b00bfd36..7e714048 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -2857,7 +2857,7 @@ TEST(AsyncSocketTest, EvbCallbacks) { socket->attachEventBase(&evb); } -#ifdef MSG_ERRQUEUE +#ifdef FOLLY_HAVE_MSG_ERRQUEUE /* copied from include/uapi/linux/net_tstamp.h */ /* SO_TIMESTAMPING gets an integer bit field comprised of these values */ enum SOF_TIMESTAMPING { @@ -2980,7 +2980,7 @@ TEST(AsyncSocketTest, ErrMessageCallback) { ASSERT_EQ( errMsgCB.gotByteSeq_ + errMsgCB.gotTimestamp_, errMsgCB.resetAfter_); } -#endif // MSG_ERRQUEUE +#endif // FOLLY_HAVE_MSG_ERRQUEUE TEST(AsyncSocket, PreReceivedData) { TestServer server; diff --git a/folly/portability/Sockets.h b/folly/portability/Sockets.h index b78ddaba..ad6b5f08 100755 --- a/folly/portability/Sockets.h +++ b/folly/portability/Sockets.h @@ -27,6 +27,7 @@ #include #ifdef MSG_ERRQUEUE +#define FOLLY_HAVE_MSG_ERRQUEUE 1 /* for struct sock_extended_err*/ #include #endif -- 2.34.1