channel: add option tcp keepalive timeout to channels

This commit is contained in:
Sunny Shin 2015-12-01 13:46:30 +09:00 committed by Christophe Fergeau
parent a81a25adc1
commit 98417d8309
4 changed files with 29 additions and 0 deletions

View File

@ -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;

View File

@ -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);
@ -3908,3 +3923,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);
}

View File

@ -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);

View File

@ -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;