Fix the build of the socket tests on Windows
authorChristopher Dykes <cdykes@fb.com>
Thu, 13 Jul 2017 18:53:11 +0000 (11:53 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 13 Jul 2017 18:57:20 +0000 (11:57 -0700)
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
folly/io/async/test/AsyncSocketTest.h
folly/io/async/test/AsyncSocketTest2.cpp

index 47e0902496687e77f13a5d06dfb4b2eb77a3f149..a8e4e4482bdf96dda536dbe5a460cc4013f3520c 100644 (file)
@@ -30,7 +30,6 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/types.h>
-#include <sys/utsname.h>
 
 #include <fstream>
 #include <iostream>
 #include <set>
 #include <thread>
 
+#ifdef MSG_ERRQUEUE
+#include <sys/utsname.h>
+#endif
+
 using std::string;
 using std::vector;
 using std::min;
index b84251f787977a4dbd5ce5157a7e0f79e49eaf8b..95f302e47deb57f46835ee3c5d346195d0190e2f 100644 (file)
@@ -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:
index 3863e1e095196258e98328ad1532fc668bebacd3..b00bfd361dc1c523b90ec0769f40357fca189a90 100644 (file)
@@ -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