Skip to content

Conversation

tsr-boxbot
Copy link
Contributor

This commit fixes closing a TCPSocket's raw socket if something goes wrong in the constructor. Presently if the socket gets opened but something else goes wrong then the file descriptor(FD) is left dangling and can quickly exhaust the system FD limit

This commit fixes closing a TCPSocket's raw socket if something goes
wrong in the constructor. Presently if the socket gets opened but
something else goes wrong then the file descriptor(FD) is left
dangling and can quickly exhaust the system FD limit
socket_->Close();
}
}
void do_not_cleanup() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not called anywhere, which means the file descriptor is always cleaned up after the constructor is finished

socket_scope_cleanup(TCPSocket* socket):socket_(socket){}
~socket_scope_cleanup() {
if(should_cleanup) {
Logger(LogLevel::DEBUG) << "Close TCP socket fd=" << _sockedFd;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Logger(LogLevel::DEBUG) << "Close TCP socket fd=" << _sockedFd;
Logger(LogLevel::DEBUG) << "Close TCP socket fd=" << socket_->_sockedFd;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants