[Spice-commits] server/reds-private.h server/reds.c server/spice-server.h server/spice-server.syms

Christophe Fergau teuf at kemper.freedesktop.org
Tue Jan 12 06:21:47 PST 2016


 server/reds-private.h    |    1 +
 server/reds.c            |   22 ++++++++++++++++++++++
 server/spice-server.h    |    1 +
 server/spice-server.syms |    5 +++++
 4 files changed, 29 insertions(+)

New commits:
commit b9b0590bc053b8fdd9b8ac04256d01a35f0cbcf7
Author: Sunny Shin <sunny4s.git at gmail.com>
Date:   Tue Dec 1 13:46:30 2015 +0900

    channel: add option tcp keepalive timeout to channels

diff --git a/server/reds-private.h b/server/reds-private.h
index 2df4ca4..7f4f04f 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -173,6 +173,7 @@ typedef struct RedsState {
     int vm_running;
     Ring char_devs_states; /* list of SpiceCharDeviceStateItem */
     int seamless_migration_enabled; /* command line arg */
+    int keepalive_timeout;
 
     SSL_CTX *ctx;
 
diff --git a/server/reds.c b/server/reds.c
index b992911..bee2574 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2326,6 +2326,21 @@ static RedLinkInfo *reds_init_client_connection(int socket)
         }
     }
 
+    if (reds->keepalive_timeout > 0) {
+        int keepalive = 1;
+        if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)) == -1) {
+            if (errno != ENOTSUP) {
+                spice_printerr("setsockopt for keepalive failed, %s", strerror(errno));
+            }
+        }
+        if (setsockopt(socket, SOL_TCP, TCP_KEEPIDLE,
+                       &reds->keepalive_timeout, sizeof(reds->keepalive_timeout)) == -1) {
+            if (errno != ENOTSUP) {
+                spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));
+            }
+        }
+    }
+
     link = spice_new0(RedLinkInfo, 1);
     link->stream = reds_stream_new(socket);
 
@@ -3998,3 +4013,10 @@ SPICE_GNUC_VISIBLE void spice_server_set_seamless_migration(SpiceServer *s, int
     reds->seamless_migration_enabled = enable && !reds->allow_multiple_clients;
     spice_debug("seamless migration enabled=%d", enable);
 }
+
+SPICE_GNUC_VISIBLE void spice_server_set_keepalive_timeout(SpiceServer *s, int timeout)
+{
+    spice_assert(s == reds);
+    reds->keepalive_timeout = timeout;
+    spice_debug("keepalive timeout=%d", timeout);
+}
diff --git a/server/spice-server.h b/server/spice-server.h
index c2ff61d..fa74136 100644
--- a/server/spice-server.h
+++ b/server/spice-server.h
@@ -111,6 +111,7 @@ int spice_server_set_playback_compression(SpiceServer *s, int enable);
 int spice_server_set_agent_mouse(SpiceServer *s, int enable);
 int spice_server_set_agent_copypaste(SpiceServer *s, int enable);
 int spice_server_set_agent_file_xfer(SpiceServer *s, int enable);
+void spice_server_set_keepalive_timeout(SpiceServer *s, int timeout);
 
 int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);
 int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);
diff --git a/server/spice-server.syms b/server/spice-server.syms
index d65e14d..4137546 100644
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -162,3 +162,8 @@ global:
     spice_replay_next_cmd;
     spice_replay_free_cmd;
 } SPICE_SERVER_0.12.5;
+
+SPICE_SERVER_0.12.7 {
+global:
+    spice_server_set_keepalive_timeout;
+} SPICE_SERVER_0.12.6;


More information about the Spice-commits mailing list