diff --git a/src/connection.cpp b/src/connection.cpp index 22e24d4..1be9328 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -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() {