We expect to get valid fds to close in ~Connection in ~Server
This commit is contained in:
@@ -59,7 +59,14 @@ Connection::Connection(struct sockaddr_storage addr, int fd, int64_t id,
|
|||||||
|
|
||||||
Connection::~Connection() {
|
Connection::~Connection() {
|
||||||
handler_->on_connection_closed(*this);
|
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() {
|
void Connection::close() {
|
||||||
|
|||||||
Reference in New Issue
Block a user