[PATCH 2/2] channel: add option tcp keepalive timeout to channels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



channel: add option tcp keepalive timeout to channels

Signed-off-by: Sunny Shin <sunny4s.git@xxxxxxxxx>
---
 server/reds-private.h    |  1 +
 server/reds.c            | 23 +++++++++++++++++++++++
 server/spice-server.h    |  1 +
 server/spice-server.syms |  1 +
 4 files changed, 26 insertions(+)

diff --git a/server/reds-private.h b/server/reds-private.h
index 790f61c..4859542 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -175,6 +175,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 8b3c3cb..692461f 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2271,6 +2271,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);

@@ -3944,3 +3959,11 @@ 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..92c26a9 100644
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -161,4 +161,5 @@ global:
     spice_replay_new;
     spice_replay_next_cmd;
     spice_replay_free_cmd;
+    spice_server_set_keepalive_timeout;
 } SPICE_SERVER_0.12.5;
--
2.5.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]