Commit 50a21b1b authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

AsyncServerSocket::ConnectionEventCallback to NetworkSocket

Summary: Just do this atomically as there's only 2 places that use this.

Reviewed By: yfeldblum

Differential Revision: D13104245

fbshipit-source-id: ca3c5271deaade071e5e497bde5eeb15d5513e59
parent 6100907a
...@@ -85,13 +85,8 @@ class AsyncServerSocket : public DelayedDestruction, public AsyncSocketBase { ...@@ -85,13 +85,8 @@ class AsyncServerSocket : public DelayedDestruction, public AsyncSocketBase {
* is accepted using the system accept()/accept4() APIs. * is accepted using the system accept()/accept4() APIs.
*/ */
virtual void onConnectionAccepted( virtual void onConnectionAccepted(
const int socket,
const SocketAddress& addr) noexcept = 0;
void onConnectionAccepted(
const NetworkSocket socket, const NetworkSocket socket,
const SocketAddress& addr) noexcept { const SocketAddress& addr) noexcept = 0;
onConnectionAccepted(socket.toFd(), addr);
}
/** /**
* onConnectionAcceptError() is called when an error occurred accepting * onConnectionAcceptError() is called when an error occurred accepting
...@@ -104,39 +99,24 @@ class AsyncServerSocket : public DelayedDestruction, public AsyncSocketBase { ...@@ -104,39 +99,24 @@ class AsyncServerSocket : public DelayedDestruction, public AsyncSocketBase {
* probably because of some error encountered. * probably because of some error encountered.
*/ */
virtual void onConnectionDropped( virtual void onConnectionDropped(
const int socket,
const SocketAddress& addr) noexcept = 0;
void onConnectionDropped(
const NetworkSocket socket, const NetworkSocket socket,
const SocketAddress& addr) noexcept { const SocketAddress& addr) noexcept = 0;
onConnectionDropped(socket.toFd(), addr);
}
/** /**
* onConnectionEnqueuedForAcceptorCallback() is called when the * onConnectionEnqueuedForAcceptorCallback() is called when the
* connection is successfully enqueued for an AcceptCallback to pick up. * connection is successfully enqueued for an AcceptCallback to pick up.
*/ */
virtual void onConnectionEnqueuedForAcceptorCallback( virtual void onConnectionEnqueuedForAcceptorCallback(
const int socket,
const SocketAddress& addr) noexcept = 0;
void onConnectionEnqueuedForAcceptorCallback(
const NetworkSocket socket, const NetworkSocket socket,
const SocketAddress& addr) noexcept { const SocketAddress& addr) noexcept = 0;
onConnectionEnqueuedForAcceptorCallback(socket.toFd(), addr);
}
/** /**
* onConnectionDequeuedByAcceptorCallback() is called when the * onConnectionDequeuedByAcceptorCallback() is called when the
* connection is successfully dequeued by an AcceptCallback. * connection is successfully dequeued by an AcceptCallback.
*/ */
virtual void onConnectionDequeuedByAcceptorCallback( virtual void onConnectionDequeuedByAcceptorCallback(
const int socket,
const SocketAddress& addr) noexcept = 0;
void onConnectionDequeuedByAcceptorCallback(
const NetworkSocket socket, const NetworkSocket socket,
const SocketAddress& addr) noexcept { const SocketAddress& addr) noexcept = 0;
onConnectionDequeuedByAcceptorCallback(socket.toFd(), addr);
}
/** /**
* onBackoffStarted is called when the socket has successfully started * onBackoffStarted is called when the socket has successfully started
......
...@@ -35,7 +35,7 @@ class TestConnectionEventCallback ...@@ -35,7 +35,7 @@ class TestConnectionEventCallback
: public AsyncServerSocket::ConnectionEventCallback { : public AsyncServerSocket::ConnectionEventCallback {
public: public:
void onConnectionAccepted( void onConnectionAccepted(
const int /* socket */, const NetworkSocket /* socket */,
const SocketAddress& /* addr */) noexcept override { const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_); folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionAccepted_++; connectionAccepted_++;
...@@ -47,21 +47,21 @@ class TestConnectionEventCallback ...@@ -47,21 +47,21 @@ class TestConnectionEventCallback
} }
void onConnectionDropped( void onConnectionDropped(
const int /* socket */, const NetworkSocket /* socket */,
const SocketAddress& /* addr */) noexcept override { const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_); folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionDropped_++; connectionDropped_++;
} }
void onConnectionEnqueuedForAcceptorCallback( void onConnectionEnqueuedForAcceptorCallback(
const int /* socket */, const NetworkSocket /* socket */,
const SocketAddress& /* addr */) noexcept override { const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_); folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionEnqueuedForAcceptCallback_++; connectionEnqueuedForAcceptCallback_++;
} }
void onConnectionDequeuedByAcceptorCallback( void onConnectionDequeuedByAcceptorCallback(
const int /* socket */, const NetworkSocket /* socket */,
const SocketAddress& /* addr */) noexcept override { const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_); folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionDequeuedByAcceptCallback_++; connectionDequeuedByAcceptCallback_++;
......
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