Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Enable SO_KEEPALIVE
This hopefully prevents unnecessary TCP timeouts.
  • Loading branch information
markus456 committed Nov 5, 2019
1 parent ca52d1c commit 03e8e85
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/core/utils.cc
Expand Up @@ -950,11 +950,15 @@ bool configure_network_socket(int so, int type)
{
int one = 1;

if (type != AF_UNIX && setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0)
if (type != AF_UNIX)
{
MXS_ERROR("Failed to set socket option: %d, %s.", errno, mxs_strerror(errno));
mxb_assert(!true);
return false;
if (setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0
|| setsockopt(so, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one)) != 0)
{
MXS_ERROR("Failed to set socket option: %d, %s.", errno, mxs_strerror(errno));
mxb_assert(!true);
return false;
}
}

return setnonblocking(so) == 0;
Expand Down

0 comments on commit 03e8e85

Please sign in to comment.