0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-08 13:08:56 +02:00

ircd::net::acceptor: Eliminate getpeername(2) for address already returned on accept(2).

This commit is contained in:
Jason Volk 2023-03-19 14:12:00 -07:00
parent c3c73fcbe7
commit f2626d39a7

View file

@ -501,7 +501,7 @@ try
sock->local = ep; sock->local = ep;
ip::tcp::socket &sd(*sock); ip::tcp::socket &sd(*sock);
a.async_accept(sd, ios::handle(accept_desc, std::move(handler))); a.async_accept(sd, sock->remote, ios::handle(accept_desc, std::move(handler)));
++accepting; ++accepting;
return true; return true;
} }
@ -527,14 +527,6 @@ noexcept try
assert(accepting > 0); assert(accepting > 0);
assert(accepting == 1); // for now assert(accepting == 1); // for now
if(likely(sock->sd.is_open()))
sock->remote = sock->sd.remote_endpoint();
const auto remote
{
remote_ipport(*sock)
};
char ecbuf[64]; char ecbuf[64];
log::debug log::debug
{ {
@ -553,6 +545,11 @@ noexcept try
return; return;
} }
const auto remote
{
remote_ipport(*sock)
};
if(unlikely(secure && !check_handshake_limit(*sock, remote))) if(unlikely(secure && !check_handshake_limit(*sock, remote)))
{ {
allow(*this); allow(*this);