Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Gauci committed Oct 29, 2018
1 parent 157a1a6 commit c853c40
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
9 changes: 0 additions & 9 deletions src/base/PipeSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ int PipeSocketHandler::connect(const SocketEndpoint& endpoint) {
FATAL_FAIL(opts);
opts |= O_NONBLOCK;
FATAL_FAIL(fcntl(sockFd, F_SETFL, opts));
// Set linger
struct linger so_linger;
so_linger.l_onoff = 1;
so_linger.l_linger = 5;
int z =
setsockopt(sockFd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof so_linger);
if (z) {
LOG(FATAL) << "set socket linger failed";
}
}

VLOG(3) << "Connecting to " << endpoint << " with fd " << sockFd;
Expand Down
1 change: 1 addition & 0 deletions src/base/ServerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bool ServerConnection::acceptNewConnection(int fd) {
return false;
}
VLOG(1) << "SERVER: got client socket fd: " << clientSocketFd;
lock_guard<std::recursive_mutex> guard(classMutex);
clientHandlerThreadPool.push(
[&, this](int id) { clientHandler(clientSocketFd); });
return true;
Expand Down
9 changes: 0 additions & 9 deletions src/base/TcpSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ int TcpSocketHandler::connect(const SocketEndpoint &endpoint) {
FATAL_FAIL(opts);
opts |= O_NONBLOCK;
FATAL_FAIL(fcntl(sockFd, F_SETFL, opts));
// Set linger
struct linger so_linger;
so_linger.l_onoff = 1;
so_linger.l_linger = 5;
int z = setsockopt(sockFd, SOL_SOCKET, SO_LINGER, &so_linger,
sizeof so_linger);
if (z) {
LOG(FATAL) << "set socket linger failed";
}
}
VLOG(4) << "Set nonblocking";
if (::connect(sockFd, p->ai_addr, p->ai_addrlen) == -1 &&
Expand Down
9 changes: 9 additions & 0 deletions src/base/UnixSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ void UnixSocketHandler::initSocket(int fd) {
sizeof(struct timeval)));
FATAL_FAIL_UNLESS_EINVAL(setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,
sizeof(struct timeval)));
// Set linger
struct linger so_linger;
so_linger.l_onoff = 1;
so_linger.l_linger = 10;
int z =
setsockopt(fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof so_linger);
if (z) {
LOG(FATAL) << "set socket linger failed";
}
#ifndef MSG_NOSIGNAL
// If we don't have MSG_NOSIGNAL, use SO_NOSIGPIPE
int val = 1;
Expand Down

0 comments on commit c853c40

Please sign in to comment.