From 7113180ac82cdd64889f0e5452d5898b37889023 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 13 Jul 2017 11:53:11 -0700 Subject: [PATCH] Fix the build of the socket tests on Windows Summary: There were references to things that don't exist or have an equivalent on Windows. Reviewed By: yfeldblum Differential Revision: D5099802 fbshipit-source-id: 9a5a2d0e5cb3a33ecad00bf8a2e1c13315a015cc --- folly/io/async/test/AsyncSSLSocketTest.cpp | 5 ++- folly/io/async/test/AsyncSocketTest.h | 38 ---------------------- folly/io/async/test/AsyncSocketTest2.cpp | 38 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/folly/io/async/test/AsyncSSLSocketTest.cpp b/folly/io/async/test/AsyncSSLSocketTest.cpp index 47e09024..a8e4e448 100644 --- a/folly/io/async/test/AsyncSSLSocketTest.cpp +++ b/folly/io/async/test/AsyncSSLSocketTest.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -38,6 +37,10 @@ #include #include +#ifdef MSG_ERRQUEUE +#include +#endif + using std::string; using std::vector; using std::min; diff --git a/folly/io/async/test/AsyncSocketTest.h b/folly/io/async/test/AsyncSocketTest.h index b84251f7..95f302e4 100644 --- a/folly/io/async/test/AsyncSocketTest.h +++ b/folly/io/async/test/AsyncSocketTest.h @@ -202,44 +202,6 @@ class BufferCallback : public folly::AsyncTransport::BufferCallback { class ReadVerifier { }; -class TestErrMessageCallback : public folly::AsyncSocket::ErrMessageCallback { - public: - TestErrMessageCallback() - : exception_(folly::AsyncSocketException::UNKNOWN, "none") - {} - - void errMessage(const cmsghdr& cmsg) noexcept override { - if (cmsg.cmsg_level == SOL_SOCKET && - cmsg.cmsg_type == SCM_TIMESTAMPING) { - gotTimestamp_++; - checkResetCallback(); - } else if ( - (cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR) || - (cmsg.cmsg_level == SOL_IPV6 && cmsg.cmsg_type == IPV6_RECVERR)) { - gotByteSeq_++; - checkResetCallback(); - } - } - - void errMessageError( - const folly::AsyncSocketException& ex) noexcept override { - exception_ = ex; - } - - void checkResetCallback() noexcept { - if (socket_ != nullptr && resetAfter_ != -1 && - gotTimestamp_ + gotByteSeq_ == resetAfter_) { - socket_->setErrMessageCB(nullptr); - } - } - - folly::AsyncSocket* socket_{nullptr}; - folly::AsyncSocketException exception_; - int gotTimestamp_{0}; - int gotByteSeq_{0}; - int resetAfter_{-1}; -}; - class TestSendMsgParamsCallback : public folly::AsyncSocket::SendMsgParamsCallback { public: diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index 3863e1e0..b00bfd36 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -2868,6 +2868,42 @@ enum SOF_TIMESTAMPING { SOF_TIMESTAMPING_OPT_TSONLY = (1 << 11), }; +class TestErrMessageCallback : public folly::AsyncSocket::ErrMessageCallback { + public: + TestErrMessageCallback() + : exception_(folly::AsyncSocketException::UNKNOWN, "none") {} + + void errMessage(const cmsghdr& cmsg) noexcept override { + if (cmsg.cmsg_level == SOL_SOCKET && cmsg.cmsg_type == SCM_TIMESTAMPING) { + gotTimestamp_++; + checkResetCallback(); + } else if ( + (cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR) || + (cmsg.cmsg_level == SOL_IPV6 && cmsg.cmsg_type == IPV6_RECVERR)) { + gotByteSeq_++; + checkResetCallback(); + } + } + + void errMessageError( + const folly::AsyncSocketException& ex) noexcept override { + exception_ = ex; + } + + void checkResetCallback() noexcept { + if (socket_ != nullptr && resetAfter_ != -1 && + gotTimestamp_ + gotByteSeq_ == resetAfter_) { + socket_->setErrMessageCB(nullptr); + } + } + + folly::AsyncSocket* socket_{nullptr}; + folly::AsyncSocketException exception_; + int gotTimestamp_{0}; + int gotByteSeq_{0}; + int resetAfter_{-1}; +}; + TEST(AsyncSocketTest, ErrMessageCallback) { TestServer server; @@ -3076,6 +3112,7 @@ TEST(AsyncSocket, PreReceivedDataTakeover) { evb.loop(); } +#ifdef MSG_NOSIGNAL TEST(AsyncSocketTest, SendMessageFlags) { TestServer server; TestSendMsgParamsCallback sendMsgCB( @@ -3228,3 +3265,4 @@ TEST(AsyncSocketTest, SendMessageAncillaryData) { magicString.end(), transferredMagicString.begin())); } +#endif -- 2.34.1