From 3c6096c286de70798feefa5b2450f433476098a5 Mon Sep 17 00:00:00 2001 From: Orvid King Date: Wed, 10 Apr 2019 14:57:55 -0700 Subject: [PATCH] AsyncServerSocket::AcceptCallback::connectionAccepted to NetworkSocket (attempt #2) Summary: The file descriptor API here needs to go away, so switch this API to NetworkSocket It is expected that this commit will cause a number of Open Source projects to temporarily show up as broken. This is due to the fact that not all projects get synced to Github at the exact same time, so the builds may temporarily be fetching an older version of it's dependencies than it needs to :) It should fix itself quickly. Reviewed By: yfeldblum Differential Revision: D14673328 fbshipit-source-id: c5842fa5dc383d50043e0d8228e35d03b10a1c6b --- folly/io/async/AsyncServerSocket.h | 7 +------ folly/io/async/test/AsyncSocketTest2.h | 6 +++--- folly/io/async/test/TestSSLServer.h | 4 +++- folly/io/async/test/ZeroCopy.h | 4 +++- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/folly/io/async/AsyncServerSocket.h b/folly/io/async/AsyncServerSocket.h index 7b45ad40910..4b851794f5e 100644 --- a/folly/io/async/AsyncServerSocket.h +++ b/folly/io/async/AsyncServerSocket.h @@ -158,13 +158,8 @@ class AsyncServerSocket : public DelayedDestruction, public AsyncSocketBase { * remain valid until connectionAccepted() returns. */ virtual void connectionAccepted( - int fd, - const SocketAddress& clientAddr) noexcept = 0; - void connectionAccepted( NetworkSocket fd, - const SocketAddress& clientAddr) noexcept { - connectionAccepted(fd.toFd(), clientAddr); - } + const SocketAddress& clientAddr) noexcept = 0; /** * acceptError() is called if an error occurs while accepting. diff --git a/folly/io/async/test/AsyncSocketTest2.h b/folly/io/async/test/AsyncSocketTest2.h index 429019bda9b..3e1a86159ef 100644 --- a/folly/io/async/test/AsyncSocketTest2.h +++ b/folly/io/async/test/AsyncSocketTest2.h @@ -182,12 +182,12 @@ class TestAcceptCallback : public AsyncServerSocket::AcceptCallback { } void connectionAccepted( - int fd, + NetworkSocket fd, const folly::SocketAddress& clientAddr) noexcept override { - events_.emplace_back(NetworkSocket::fromFd(fd), clientAddr); + events_.emplace_back(fd, clientAddr); if (connectionAcceptedFn_) { - connectionAcceptedFn_(NetworkSocket::fromFd(fd), clientAddr); + connectionAcceptedFn_(fd, clientAddr); } } void acceptError(const std::exception& ex) noexcept override { diff --git a/folly/io/async/test/TestSSLServer.h b/folly/io/async/test/TestSSLServer.h index b5c5f171449..b591e6d0afe 100644 --- a/folly/io/async/test/TestSSLServer.h +++ b/folly/io/async/test/TestSSLServer.h @@ -61,8 +61,10 @@ class SSLServerAcceptCallbackBase : public AsyncServerSocket::AcceptCallback { } void connectionAccepted( - int fd, + folly::NetworkSocket fdNetworkSocket, const SocketAddress& /* clientAddr */) noexcept override { + int fd = fdNetworkSocket.toFd(); + if (socket_) { socket_->detachEventBase(); } diff --git a/folly/io/async/test/ZeroCopy.h b/folly/io/async/test/ZeroCopy.h index 8a11b648aa4..4d82629c112 100644 --- a/folly/io/async/test/ZeroCopy.h +++ b/folly/io/async/test/ZeroCopy.h @@ -227,8 +227,10 @@ class ZeroCopyTestServer : public folly::AsyncServerSocket::AcceptCallback { } void connectionAccepted( - int fd, + folly::NetworkSocket fdNetworkSocket, const folly::SocketAddress& /* unused */) noexcept override { + int fd = fdNetworkSocket.toFd(); + auto client = std::make_shared( nullptr, evb_,