<div dir="ltr"><div>channel: add option tcp keepalive timeout to channels</div><div><br></div><div>Signed-off-by: Sunny Shin <<a href="mailto:sunny4s.git@gmail.com">sunny4s.git@gmail.com</a>></div><div>---</div><div> server/reds-private.h    |  1 +</div><div> server/reds.c            | 23 +++++++++++++++++++++++</div><div> server/spice-server.h    |  1 +</div><div> server/spice-server.syms |  1 +</div><div> 4 files changed, 26 insertions(+)</div><div><br></div><div>diff --git a/server/reds-private.h b/server/reds-private.h</div><div>index 790f61c..4859542 100644</div><div>--- a/server/reds-private.h</div><div>+++ b/server/reds-private.h</div><div>@@ -175,6 +175,7 @@ typedef struct RedsState {</div><div>     int vm_running;</div><div>     Ring char_devs_states; /* list of SpiceCharDeviceStateItem */</div><div>     int seamless_migration_enabled; /* command line arg */</div><div>+    int keepalive_timeout;</div><div><br></div><div>     SSL_CTX *ctx;</div><div><br></div><div>diff --git a/server/reds.c b/server/reds.c</div><div>index 8b3c3cb..692461f 100644</div><div>--- a/server/reds.c</div><div>+++ b/server/reds.c</div><div>@@ -2271,6 +2271,21 @@ static RedLinkInfo *reds_init_client_connection(int socket)</div><div>         }</div><div>     }</div><div><br></div><div>+    if (reds->keepalive_timeout > 0) {</div><div>+        int keepalive = 1;</div><div>+        if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)) == -1) {</div><div>+            if (errno != ENOTSUP) {</div><div>+                spice_printerr("setsockopt for keepalive failed, %s", strerror(errno));</div><div>+            }</div><div>+        }</div><div>+        if (setsockopt(socket, SOL_TCP, TCP_KEEPIDLE,</div><div>+                       &reds->keepalive_timeout, sizeof(reds->keepalive_timeout)) == -1) {</div><div>+            if (errno != ENOTSUP) {</div><div>+                spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));</div><div>+            }</div><div>+        }</div><div>+    }</div><div>+</div><div>     link = spice_new0(RedLinkInfo, 1);</div><div>     link->stream = reds_stream_new(socket);<br></div><div><div><br></div><div>@@ -3944,3 +3959,11 @@ SPICE_GNUC_VISIBLE void spice_server_set_seamless_migration(SpiceServer *s, int</div><div>     reds->seamless_migration_enabled = enable && !reds->allow_multiple_clients;</div><div>     spice_debug("seamless migration enabled=%d", enable);</div><div> }</div><div>+</div><div>+SPICE_GNUC_VISIBLE void spice_server_set_keepalive_timeout(SpiceServer *s, int timeout)</div><div>+{</div><div>+    spice_assert(s == reds);</div><div>+    reds->keepalive_timeout = timeout;</div><div>+    spice_debug("keepalive timeout=%d", timeout);</div><div>+}</div><div>+</div><div>diff --git a/server/spice-server.h b/server/spice-server.h</div><div>index c2ff61d..fa74136 100644</div><div>--- a/server/spice-server.h</div><div>+++ b/server/spice-server.h</div><div>@@ -111,6 +111,7 @@ int spice_server_set_playback_compression(SpiceServer *s, int enable);</div><div> int spice_server_set_agent_mouse(SpiceServer *s, int enable);</div><div> int spice_server_set_agent_copypaste(SpiceServer *s, int enable);</div><div> int spice_server_set_agent_file_xfer(SpiceServer *s, int enable);</div><div>+void spice_server_set_keepalive_timeout(SpiceServer *s, int timeout);</div><div><br></div><div> int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);</div><div> int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);</div><div>diff --git a/server/spice-server.syms b/server/spice-server.syms</div><div>index d65e14d..92c26a9 100644</div><div>--- a/server/spice-server.syms</div><div>+++ b/server/spice-server.syms</div><div>@@ -161,4 +161,5 @@ global:</div><div>     spice_replay_new;</div><div>     spice_replay_next_cmd;</div><div>     spice_replay_free_cmd;</div><div>+    spice_server_set_keepalive_timeout;</div><div> } SPICE_SERVER_0.12.5;</div><div>--</div><div>2.5.0</div></div><div><br></div></div>