Commit 3beebd30 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Attempt to migrate some things

Summary: temp

Reviewed By: yfeldblum

Differential Revision: D14882681

fbshipit-source-id: 3017cb9743c81396764e6a61bdca183ae2692401
parent 4ebfe3cf
......@@ -34,16 +34,28 @@ class SocketPair {
void closeFD0();
void closeFD1();
NetworkSocket extractNetworkSocket0() {
return extractNetworkSocket(0);
}
NetworkSocket extractNetworkSocket1() {
return extractNetworkSocket(1);
}
int extractFD0() {
return extractFD(0);
return extractNetworkSocket0().toFd();
}
int extractFD1() {
return extractFD(1);
return extractNetworkSocket1().toFd();
}
int extractFD(int index) {
NetworkSocket extractNetworkSocket(int index) {
auto fd = fds_[index];
fds_[index] = NetworkSocket();
return fd.toFd();
return fd;
}
int extractFD(int index) {
return extractNetworkSocket(index).toFd();
}
private:
......
......@@ -61,10 +61,8 @@ class SSLServerAcceptCallbackBase : public AsyncServerSocket::AcceptCallback {
}
void connectionAccepted(
folly::NetworkSocket fdNetworkSocket,
folly::NetworkSocket fd,
const SocketAddress& /* clientAddr */) noexcept override {
int fd = fdNetworkSocket.toFd();
if (socket_) {
socket_->detachEventBase();
}
......@@ -72,13 +70,12 @@ class SSLServerAcceptCallbackBase : public AsyncServerSocket::AcceptCallback {
try {
// Create a AsyncSSLSocket object with the fd. The socket should be
// added to the event base and in the state of accepting SSL connection.
socket_ = AsyncSSLSocket::newSocket(
ctx_, base_, folly::NetworkSocket::fromFd(fd));
socket_ = AsyncSSLSocket::newSocket(ctx_, base_, fd);
} catch (const std::exception& e) {
LOG(ERROR) << "Exception %s caught while creating a AsyncSSLSocket "
"object with socket "
<< e.what() << fd;
::close(fd);
folly::netops::close(fd);
acceptError(e);
return;
}
......
......@@ -227,17 +227,10 @@ class ZeroCopyTestServer : public folly::AsyncServerSocket::AcceptCallback {
}
void connectionAccepted(
folly::NetworkSocket fdNetworkSocket,
folly::NetworkSocket fd,
const folly::SocketAddress& /* unused */) noexcept override {
int fd = fdNetworkSocket.toFd();
auto client = std::make_shared<ZeroCopyTestAsyncSocket>(
nullptr,
evb_,
NetworkSocket::fromFd(fd),
numLoops_,
bufferSize_,
zeroCopy_);
nullptr, evb_, fd, numLoops_, bufferSize_, zeroCopy_);
clients_[client.get()] = client;
}
......
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