event/ServerSocket: make OneServerSocket an inner class

This commit is contained in:
Max Kellermann 2018-10-30 20:16:26 +01:00
parent 0307b49f43
commit c6f61a699c
2 changed files with 7 additions and 8 deletions

View File

@ -52,7 +52,7 @@
#include <netdb.h> #include <netdb.h>
#endif #endif
class OneServerSocket final : private SocketMonitor { class ServerSocket::OneServerSocket final : private SocketMonitor {
ServerSocket &parent; ServerSocket &parent;
const unsigned serial; const unsigned serial;
@ -146,7 +146,7 @@ get_remote_uid(int fd)
} }
inline void inline void
OneServerSocket::Accept() noexcept ServerSocket::OneServerSocket::Accept() noexcept
{ {
StaticSocketAddress peer_address; StaticSocketAddress peer_address;
UniqueSocketDescriptor peer_fd(GetSocket().AcceptNonBlock(peer_address)); UniqueSocketDescriptor peer_fd(GetSocket().AcceptNonBlock(peer_address));
@ -170,14 +170,14 @@ OneServerSocket::Accept() noexcept
} }
bool bool
OneServerSocket::OnSocketReady(gcc_unused unsigned flags) noexcept ServerSocket::OneServerSocket::OnSocketReady(gcc_unused unsigned flags) noexcept
{ {
Accept(); Accept();
return true; return true;
} }
inline void inline void
OneServerSocket::Open() ServerSocket::OneServerSocket::Open()
{ {
assert(!IsDefined()); assert(!IsDefined());
@ -272,7 +272,7 @@ ServerSocket::Close() noexcept
i.Close(); i.Close();
} }
OneServerSocket & ServerSocket::OneServerSocket &
ServerSocket::AddAddress(SocketAddress address) noexcept ServerSocket::AddAddress(SocketAddress address) noexcept
{ {
sockets.emplace_back(loop, *this, next_serial, sockets.emplace_back(loop, *this, next_serial,
@ -281,7 +281,7 @@ ServerSocket::AddAddress(SocketAddress address) noexcept
return sockets.back(); return sockets.back();
} }
OneServerSocket & ServerSocket::OneServerSocket &
ServerSocket::AddAddress(AllocatedSocketAddress &&address) noexcept ServerSocket::AddAddress(AllocatedSocketAddress &&address) noexcept
{ {
sockets.emplace_back(loop, *this, next_serial, sockets.emplace_back(loop, *this, next_serial,

View File

@ -27,13 +27,12 @@ class AllocatedSocketAddress;
class UniqueSocketDescriptor; class UniqueSocketDescriptor;
class EventLoop; class EventLoop;
class AllocatedPath; class AllocatedPath;
class OneServerSocket;
/** /**
* A socket that accepts incoming stream connections (e.g. TCP). * A socket that accepts incoming stream connections (e.g. TCP).
*/ */
class ServerSocket { class ServerSocket {
friend class OneServerSocket; class OneServerSocket;
EventLoop &loop; EventLoop &loop;