From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LwjuF-0006z4-0M for qemu-devel@nongnu.org; Wed, 22 Apr 2009 17:22:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LwjuA-0006y7-Ez for qemu-devel@nongnu.org; Wed, 22 Apr 2009 17:22:58 -0400 Received: from [199.232.76.173] (port=39633 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LwjuA-0006y4-5W for qemu-devel@nongnu.org; Wed, 22 Apr 2009 17:22:54 -0400 Received: from sj-iport-1.cisco.com ([171.71.176.70]:5919) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1Lwju9-00009Z-Lw for qemu-devel@nongnu.org; Wed, 22 Apr 2009 17:22:53 -0400 Message-ID: <49EF8A85.5020903@cisco.com> Date: Wed, 22 Apr 2009 15:22:13 -0600 From: "David S. Ahern" MIME-Version: 1.0 Subject: Re: [Qemu-devel] PATCH: enabling TCP keepalives on VNC connections References: <49EE7E35.5050908@cisco.com> <49EF614B.9000601@us.ibm.com> In-Reply-To: <49EF614B.9000601@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org Anthony Liguori wrote: > David S. Ahern wrote: >> Something is blocking this message from my gmail account; trying again >> with this one. >> >> This patch enables TCP keepalives on VNC connections for linux hosts. >> After 60-seconds of idle time, probes are sent every 12 seconds with the >> connection resetting after 5 failed probes (ie., connection is closed if >> no response received in 60-seconds). >> >> Signed-off-by: David Ahern >> >> >> david >> diff --git a/vnc.c b/vnc.c >> index ab1f044..7a8bbd7 100644 >> --- a/vnc.c >> +++ b/vnc.c >> @@ -32,6 +32,12 @@ >> >> #define VNC_REFRESH_INTERVAL (1000 / 30) >> >> +#ifdef __linux__ >> +#define VNC_TCP_KEEPIDLE 60 >> +#define VNC_TCP_KEEPINTVL 12 >> +#define VNC_TCP_KEEPCNT 5 >> +#endif >> > > Should probe in configure and make an appropriate CONFIG_. This is not > necessarily a linux specific feature. ok. I can only test on linux and mac os x; I do not have a means for building on windows. > >> #include "vnc_keysym.h" >> #include "d3des.h" >> >> @@ -2015,12 +2021,41 @@ static void vnc_listen_read(void *opaque) >> VncDisplay *vs = opaque; >> struct sockaddr_in addr; >> socklen_t addrlen = sizeof(addr); >> + int val; >> >> /* Catch-up */ >> vga_hw_update(); >> >> int csock = accept(vs->lsock, (struct sockaddr *)&addr, &addrlen); >> if (csock != -1) { >> +#ifdef __linux__ >> + /* best effort to enable keep alives */ >> + val = 1; >> + if (setsockopt(csock, SOL_SOCKET, SO_KEEPALIVE, >> + &val, sizeof(val)) < 0) { >> + fprintf(stderr, "VNC: failed to enable keepalives\n"); >> + } >> > > If we want to enable keep alive universally, wouldn't we also want it on > the tcp: character devices? > Ok. I can make a generic library call that takes the timers as input options. If the timer is 0 means leave at OS default. What about other accept() callers - e.g.,gdbstub? I'll take a look at this end of next week after my vacation around this weekend. david