session UPDATE set keepalives on accepted sockets
... instead of the listening socket. Makes the
code cleaner and some TCP/IP implementations
do not support changing these options on listening
sockets.
diff --git a/src/session_client.c b/src/session_client.c
index abb6f37..f9351c2 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -1624,20 +1624,9 @@
}
/* configure keepalives */
- if (nc_sock_configure_ka(sock, ka->enabled)) {
+ if (nc_sock_configure_ka(sock, ka)) {
goto cleanup;
}
- if (ka->enabled) {
- if (nc_sock_configure_ka_idle_time(sock, ka->idle_time)) {
- goto cleanup;
- }
- if (nc_sock_configure_ka_max_probes(sock, ka->max_probes)) {
- goto cleanup;
- }
- if (nc_sock_configure_ka_probe_interval(sock, ka->probe_interval)) {
- goto cleanup;
- }
- }
/* connected */
if (sock_pending) {
@@ -1748,7 +1737,7 @@
NC_CHECK_ARG_RET(NULL, address, port, -1);
- sock = nc_sock_listen_inet(address, port, &client_opts.ka);
+ sock = nc_sock_listen_inet(address, port);
if (sock == -1) {
return -1;
}
@@ -1852,6 +1841,13 @@
return sock;
}
+ /* configure keepalives */
+ if (nc_sock_configure_ka(sock, &client_opts.ka)) {
+ free(host);
+ close(sock);
+ return -1;
+ }
+
if (client_opts.ch_binds_aux[idx].ti == NC_TI_LIBSSH) {
*session = nc_accept_callhome_ssh_sock(sock, host, port, ctx, NC_TRANSPORT_TIMEOUT);
} else if (client_opts.ch_binds_aux[idx].ti == NC_TI_OPENSSL) {