Commit 7113180a authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

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
parent 050671f8
......@@ -30,7 +30,6 @@
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <fstream>
#include <iostream>
......@@ -38,6 +37,10 @@
#include <set>
#include <thread>
#ifdef MSG_ERRQUEUE
#include <sys/utsname.h>
#endif
using std::string;
using std::vector;
using std::min;
......
......@@ -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:
......
......@@ -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
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