mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-14 03:35:52 +00:00
channel: add option tcp keepalive timeout to channels
This commit is contained in:
parent
a81a25adc1
commit
98417d8309
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user