Skip to content

Commit

Permalink
UCT/TCP: Increase keepalive interval from 1 to 2 seconds and use syst…
Browse files Browse the repository at this point in the history
…em default for keepalive retries count
  • Loading branch information
dmitrygx committed Jul 14, 2021
1 parent 8d5552e commit 7b3112d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/uct/tcp/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#define UCT_TCP_EP_DEFAULT_KEEPALIVE_IDLE 10

/* The seconds between individual keepalive probes */
#define UCT_TCP_EP_DEFAULT_KEEPALIVE_INTVL 1
#define UCT_TCP_EP_DEFAULT_KEEPALIVE_INTVL 2


/**
Expand Down Expand Up @@ -402,7 +402,7 @@ typedef struct uct_tcp_iface {
ucs_time_t idle; /* The time the connection needs to remain
* idle before TCP starts sending keepalive
* probes (TCP_KEEPIDLE socket option) */
unsigned cnt; /* The maximum number of keepalive probes TCP
size_t cnt; /* The maximum number of keepalive probes TCP
* should send before dropping the connection
* (TCP_KEEPCNT socket option). */
ucs_time_t intvl; /* The time between individual keepalive
Expand Down Expand Up @@ -440,7 +440,7 @@ typedef struct uct_tcp_iface_config {
ucs_range_spec_t port_range;
struct {
ucs_time_t idle;
unsigned cnt;
size_t cnt;
ucs_time_t intvl;
} keepalive;
} uct_tcp_iface_config_t;
Expand Down
12 changes: 7 additions & 5 deletions src/uct/tcp/tcp_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,13 @@ static ucs_status_t uct_tcp_ep_keepalive_enable(uct_tcp_ep_t *ep)
return status;
}

status = ucs_socket_setopt(ep->fd, IPPROTO_TCP, TCP_KEEPCNT,
&iface->config.keepalive.cnt,
sizeof(iface->config.keepalive.cnt));
if (status != UCS_OK) {
return status;
if (iface->config.keepalive.cnt != UCS_ULUNITS_AUTO) {
status = ucs_socket_setopt(ep->fd, IPPROTO_TCP, TCP_KEEPCNT,
&iface->config.keepalive.cnt,
sizeof(iface->config.keepalive.cnt));
if (status != UCS_OK) {
return status;
}
}

status = ucs_socket_setopt(ep->fd, IPPROTO_TCP, TCP_KEEPIDLE,
Expand Down
6 changes: 3 additions & 3 deletions src/uct/tcp/tcp_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ static ucs_config_field_t uct_tcp_iface_config_table[] = {
ucs_offsetof(uct_tcp_iface_config_t, keepalive.idle),
UCS_CONFIG_TYPE_TIME_UNITS},

{"KEEPCNT", "3",
{"KEEPCNT", "auto",
"The maximum number of keepalive probes TCP should send before "
"dropping the connection.",
ucs_offsetof(uct_tcp_iface_config_t, keepalive.cnt),
UCS_CONFIG_TYPE_UINT},
UCS_CONFIG_TYPE_ULUNITS},

{"KEEPINTVL", UCS_PP_MAKE_STRING(UCT_TCP_EP_DEFAULT_KEEPALIVE_INTVL) "s",
"The time between individual keepalive probes.",
Expand Down Expand Up @@ -872,7 +872,7 @@ int uct_tcp_keepalive_is_enabled(uct_tcp_iface_t *iface)
{
#ifdef UCT_TCP_EP_KEEPALIVE
return (iface->config.keepalive.idle != UCS_TIME_INFINITY) &&
(iface->config.keepalive.cnt != 0) &&
(iface->config.keepalive.cnt != UCS_ULUNITS_INF) &&
(iface->config.keepalive.intvl != UCS_TIME_INFINITY);
#else /* UCT_TCP_EP_KEEPALIVE */
return 0;
Expand Down

0 comments on commit 7b3112d

Please sign in to comment.