Skip to content

Commit

Permalink
Fix bug where LINGER was being set for unix sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Gauci committed Dec 24, 2019
1 parent c457ba8 commit 1479bdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/base/TcpSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,5 +250,13 @@ void TcpSocketHandler::initSocket(int fd) {
FATAL_FAIL_UNLESS_EINVAL(
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)));
}
{
// Set linger if possible
struct linger so_linger;
so_linger.l_onoff = 1;
so_linger.l_linger = 5;
FATAL_FAIL_UNLESS_EINVAL(
setsockopt(fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof so_linger));
}
}
} // namespace et
8 changes: 0 additions & 8 deletions src/base/UnixSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,6 @@ vector<int> UnixSocketHandler::getActiveSockets() {
}

void UnixSocketHandler::initSocket(int fd) {
{
// Set linger
struct linger so_linger;
so_linger.l_onoff = 1;
so_linger.l_linger = 5;
FATAL_FAIL_UNLESS_EINVAL(
setsockopt(fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof so_linger));
}
#ifndef MSG_NOSIGNAL
{
// If we don't have MSG_NOSIGNAL, use SO_NOSIGPIPE
Expand Down

0 comments on commit 1479bdc

Please sign in to comment.