Bug 45899 - Add keepalive on different channel
Summary: Add keepalive on different channel
Status: RESOLVED FIXED
Alias: None
Product: Spice
Classification: Unclassified
Component: spice-gtk (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Spice Bug List
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-10 08:37 UTC by prochazka.nicolas
Modified: 2012-02-13 02:36 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description prochazka.nicolas 2012-02-10 08:37:27 UTC
Without keepalive on each connection(channel), 
channel is destroyed after ip_conntrack_tcp_timeout_established timeout.



spice client establish connection to spice server.

DEV-10.98.98.1:~# conntrack -L |grep 11943
conntrack v1.0.0 (conntrack-tools): 76 flow entries have been shown.
tcp      6 600 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44970
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44970
[ASSURED] mark=0 use=1
tcp      6 600 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44971
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44971
[ASSURED] mark=0 use=1
tcp      6 600 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44967
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44967
[ASSURED] mark=0 use=1
tcp      6 600 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44966
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44966
[ASSURED] mark=0 use=1
tcp      6 599 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44969
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44969
[ASSURED] mark=0 use=1
tcp      6 600 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44968
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44968
[ASSURED] mark=0 use=1

my ip_conntrack_tcp_timeout_established  is set to 600 for network
performance consideration, by default it seems to be 5 days.

spice client ( spicy ) is connected to vm guest ( windows) in
screesaver mode, so there's no mouse, or keyboard event.

tcp      6 365 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44970
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44970
[ASSURED] mark=0 use=1
tcp      6 305 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44971
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44971
[ASSURED] mark=0 use=1
conntrack v1.0.0 (conntrack-tools): 72 flow entries have been shown.
tcp      6 302 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44967
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44967
[ASSURED] mark=0 use=1
tcp      6 302 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44966
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44966
[ASSURED] mark=0 use=1
tcp      6 595 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44969
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44969
[ASSURED] mark=0 use=1
tcp      6 302 ESTABLISHED src=10.10.4.3 dst=10.10.4.226 sport=44968
dport=5930 src=10.98.98.1 dst=10.10.4.3 sport=11943 dport=44968
[ASSURED] mark=0 use=1

then after 600s

tcp      6 595 ESTABLISHED src=10.10.106.58 dst=10.10.4.226
sport=53868 dport=11943 src=10.10.4.226 dst=10.10.106.58 sport=11943
dport=53868 [ASSURED] mark=0 use=1

( connection for display ( screesaver send image change )


=> Then mouse, keyboard are lost , i cannot  reuse them, I must kill
and restart spice client .
Comment 1 Marc-Andre Lureau 2012-02-10 08:43:18 UTC
I guess setting g_socket_set_keepalive (channel_socket, TRUE) should be enough.

Would you be kind enough to make a patch and try it?

thanks a lot
Comment 2 prochazka.nicolas 2012-02-10 10:15:49 UTC
I'm trying some dev without success.
I add g_socket_set_keepalive (c->sock, TRUE);
in spice-session.c and spice-channel.c but keepalive not set.

So I do a LD_PRELOAD wrapper to keepalive all socket, without success with spicy 
but succes with socat 

Any help ?

1 / 
socat - TCP4:10.10.4.226:5930
tcp        0      0 192.150.23.165:32968    10.10.4.226:5930        ESTABLISHED 0          72551      3361/socat           off (0.00/0/0)

2 /
LD_PRELOAD=/tmp/keepalive.so socat - TCP4:10.10.4.226:5930
tcp        0      0 192.150.23.165:32964    10.10.4.226:5930        ESTABLISHED 0          72354      3357/socat           keepalive (9.45/0/0)


1/spicy -h 10.10.4.226 -p 5930
tcp        0      0 192.150.23.165:32959    10.10.4.226:5930        ESTABLISHED 0          72233      3351/spicy           off (0.00/0/0)
( 6 lines  )

LD_PRELOAD=/tmp/keepalive.so spicy -h 10.10.4.226 -p 5930
tcp        0      0 192.150.23.165:32959    10.10.4.226:5930        ESTABLISHED 0          72233      3351/spicy           off (0.00/0/0)
( 6 lines  )
Comment 3 prochazka.nicolas 2012-02-13 02:36:52 UTC
as marc andre says, just set keepalive flag resolved this issue.
Thanks.
Nicolas.


diff --git a/spice-gtk-0.9/gtk/spice-channel.c b/tmp/spice-gtk-0.9/gtk/spice-channel.c
index bdfb02b..49c69c9 100644
--- a/spice-gtk-0.9/gtk/spice-channel.c
+++ b/tmp/spice-gtk-0.9/gtk/spice-channel.c
@@ -2096,6 +2096,7 @@ static void *spice_channel_coroutine(void *data)
        }
 
        g_socket_set_blocking(c->sock, FALSE);
+       g_socket_set_keepalive(c->sock, TRUE);
         goto connected;
     }



diff --git a/spice-gtk-0.9/gtk/spice-session.c b/tmp/spice-gtk-0.9/gtk/spice-session.c
index 33c297a..0156f94 100644
--- a/spice-gtk-0.9/gtk/spice-session.c
+++ b/tmp/spice-gtk-0.9/gtk/spice-session.c
@@ -1417,6 +1417,7 @@ static GSocket *channel_connect_socket(SpiceChannel *channel,
         return NULL;
 
     g_socket_set_blocking(sock, FALSE);
+    g_socket_set_keepalive(sock, TRUE);
     if (!g_socket_connect(sock, sockaddr, NULL, error)) {
         if (*error && (*error)->code == G_IO_ERROR_PENDING) {
             g_clear_error(error);


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.