[server] Better logging on shutdown from failed getpeername

pull/35611/head
AJ Heller 10 months ago
parent 1751f1043e
commit 2d1e69aff0
  1. 10
      src/core/lib/event_engine/posix_engine/posix_engine_listener.cc
  2. 10
      src/core/lib/iomgr/tcp_server_posix.cc

@ -186,8 +186,14 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::NotifyOnAccept(
if (addr.address()->sa_family == AF_UNIX) {
socklen_t len = EventEngine::ResolvedAddress::MAX_SIZE_BYTES;
if (getpeername(fd, const_cast<sockaddr*>(addr.address()), &len) < 0) {
gpr_log(GPR_ERROR, "Closing acceptor. Failed getpeername: %s",
strerror(errno));
auto listener_addr_uri = ResolvedAddressToURI(socket_.addr);
gpr_log(
GPR_ERROR,
"Failed getpeername: %s. This is a critical failure, the "
"listener on %s:%d is shutting down.",
strerror(errno),
listener_addr_uri.ok() ? listener_addr_uri->c_str() : "<unknown>",
socket_.port);
close(fd);
// Shutting down the acceptor. Unref the ref grabbed in
// AsyncConnectionAcceptor::Start().

@ -420,8 +420,14 @@ static void on_read(void* arg, grpc_error_handle err) {
addr.len = static_cast<socklen_t>(sizeof(struct sockaddr_storage));
if (getpeername(fd, reinterpret_cast<struct sockaddr*>(addr.addr),
&(addr.len)) < 0) {
gpr_log(GPR_ERROR, "Failed getpeername: %s",
grpc_core::StrError(errno).c_str());
auto listener_addr_uri = grpc_sockaddr_to_uri(&sp->addr);
gpr_log(
GPR_ERROR,
"Failed getpeername: %s. This is a critical failure, the "
"listener on %s:%d is shutting down.",
grpc_core::StrError(errno).c_str(),
listener_addr_uri.ok() ? listener_addr_uri->c_str() : "<unknown>",
sp->port);
close(fd);
goto error;
}

Loading…
Cancel
Save