Commit 6b559d40 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

AsyncServerSocket::AcceptCallback::connectionAccepted to NetworkSocket

Summary: This is a largely automated codemod that shifts `folly::AsyncServerSocket::AcceptCallback::connectionAccepted` to taking a `NetworkSocket` rather than a file descriptor. This needs to be done as a single atomic change to avoid breaking things.

Reviewed By: yfeldblum

Differential Revision: D13966702

fbshipit-source-id: 415622dc347de53368c404dfbe9a2deae5b75e18
parent b9a450ef
...@@ -158,13 +158,8 @@ class AsyncServerSocket : public DelayedDestruction, public AsyncSocketBase { ...@@ -158,13 +158,8 @@ class AsyncServerSocket : public DelayedDestruction, public AsyncSocketBase {
* remain valid until connectionAccepted() returns. * remain valid until connectionAccepted() returns.
*/ */
virtual void connectionAccepted( virtual void connectionAccepted(
int fd,
const SocketAddress& clientAddr) noexcept = 0;
void connectionAccepted(
NetworkSocket fd, NetworkSocket fd,
const SocketAddress& clientAddr) noexcept { const SocketAddress& clientAddr) noexcept = 0;
connectionAccepted(fd.toFd(), clientAddr);
}
/** /**
* acceptError() is called if an error occurs while accepting. * acceptError() is called if an error occurs while accepting.
......
...@@ -182,12 +182,12 @@ class TestAcceptCallback : public AsyncServerSocket::AcceptCallback { ...@@ -182,12 +182,12 @@ class TestAcceptCallback : public AsyncServerSocket::AcceptCallback {
} }
void connectionAccepted( void connectionAccepted(
int fd, NetworkSocket fd,
const folly::SocketAddress& clientAddr) noexcept override { const folly::SocketAddress& clientAddr) noexcept override {
events_.emplace_back(NetworkSocket::fromFd(fd), clientAddr); events_.emplace_back(fd, clientAddr);
if (connectionAcceptedFn_) { if (connectionAcceptedFn_) {
connectionAcceptedFn_(NetworkSocket::fromFd(fd), clientAddr); connectionAcceptedFn_(fd, clientAddr);
} }
} }
void acceptError(const std::exception& ex) noexcept override { void acceptError(const std::exception& ex) noexcept override {
......
...@@ -61,8 +61,10 @@ class SSLServerAcceptCallbackBase : public AsyncServerSocket::AcceptCallback { ...@@ -61,8 +61,10 @@ class SSLServerAcceptCallbackBase : public AsyncServerSocket::AcceptCallback {
} }
void connectionAccepted( void connectionAccepted(
int fd, folly::NetworkSocket fdNetworkSocket,
const SocketAddress& /* clientAddr */) noexcept override { const SocketAddress& /* clientAddr */) noexcept override {
int fd = fdNetworkSocket.toFd();
if (socket_) { if (socket_) {
socket_->detachEventBase(); socket_->detachEventBase();
} }
......
...@@ -227,8 +227,10 @@ class ZeroCopyTestServer : public folly::AsyncServerSocket::AcceptCallback { ...@@ -227,8 +227,10 @@ class ZeroCopyTestServer : public folly::AsyncServerSocket::AcceptCallback {
} }
void connectionAccepted( void connectionAccepted(
int fd, folly::NetworkSocket fdNetworkSocket,
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, evb_, fd, numLoops_, bufferSize_, zeroCopy_); nullptr, evb_, 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