summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunny Shin <sunny4s.git@gmail.com>2015-12-01 13:46:30 +0900
committerChristophe Fergeau <cfergeau@redhat.com>2016-01-12 15:10:47 +0100
commitb9b0590bc053b8fdd9b8ac04256d01a35f0cbcf7 (patch)
tree098029e2d5661d1bbfe865623e6a9057c06ee705
parent02c8a0f3865343a5153ec0a743b8a0dc4c31cbff (diff)
channel: add option tcp keepalive timeout to channels
-rw-r--r--server/reds-private.h1
-rw-r--r--server/reds.c22
-rw-r--r--server/spice-server.h1
-rw-r--r--server/spice-server.syms5
4 files changed, 29 insertions, 0 deletions
diff --git a/server/reds-private.h b/server/reds-private.h
index 2df4ca4d..7f4f04fb 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 b9929119..bee25741 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 c2ff61d6..fa741360 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 d65e14d9..4137546c 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;