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