Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-33147 Add a function to allow keep-alive to be explicitly set #19369

Open
wants to merge 1 commit into
base: candidate-9.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions system/jlib/jsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ static void queryTCPSettings()
}
}

extern jlib_decl bool queryKeepAlive(int &time, int &intvl, int &probes)
bool queryKeepAlive(int &time, int &intvl, int &probes)
{
queryTCPSettings();
if (hasKeepAlive)
Expand All @@ -474,6 +474,16 @@ extern jlib_decl bool queryKeepAlive(int &time, int &intvl, int &probes)
return hasKeepAlive;
}

void setKeepAlive(bool enabled, int time, int intvl, int probes)
{
CriticalBlock block(queryTCPCS);
keepAliveTime = time ? time : 200;
keepAliveInterval = intvl ? intvl : 75;
keepAliveProbes = probes ? probes : 9;
hasKeepAlive = enabled;
expertTCPSettings = INITED;
}

static int getAddressInfo(const char *name, unsigned *netaddr, bool okToLogErr);

static CriticalSection queryDNSCS;
Expand Down Expand Up @@ -1337,7 +1347,7 @@ void CSocket::setKeepAlive(bool set, int time, int intvl, int probes)
optval = intvl;
srtn = setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, (char *)&optval, optlen);
if (srtn != 0)
OWARNLOG("KeepAlive probes not set");
OWARNLOG("KeepAlive interval not set");
}

if (probes >= 0)
Expand Down
1 change: 1 addition & 0 deletions system/jlib/jsocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extern jlib_decl IpAddress &GetHostIp(IpAddress &ip);
extern jlib_decl IpAddress &localHostToNIC(IpAddress &ip);

extern jlib_decl bool queryKeepAlive(int &time, int &intvl, int &probes);
extern jlib_decl void setKeepAlive(bool enabled, int time=0, int intvl=0, int probes=0);

class jlib_decl SocketEndpoint : extends IpAddress
{
Expand Down
Loading