We expect to get valid fds to close in ~Connection in ~Server

This commit is contained in:
2025-09-15 00:07:09 -04:00
parent 022a79bf5b
commit eb98e51867

View File

@@ -59,7 +59,14 @@ Connection::Connection(struct sockaddr_storage addr, int fd, int64_t id,
Connection::~Connection() {
handler_->on_connection_closed(*this);
assert(fd_ < 0 && "Connection fd was not closed before ~Connection");
if (fd_ >= 0) {
int e = ::close(fd_);
if (e == -1 && errno != EINTR) {
perror("close");
std::abort();
}
// EINTR ignored - fd is guaranteed closed on Linux
}
}
void Connection::close() {