qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: "David S. Ahern" <daahern@cisco.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] PATCH: enabling TCP keepalives on VNC connections
Date: Wed, 22 Apr 2009 13:26:19 -0500	[thread overview]
Message-ID: <49EF614B.9000601@us.ibm.com> (raw)
In-Reply-To: <49EE7E35.5050908@cisco.com>

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 <dsahern@gmail.com>
>
>
> 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.

>  #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?

-- 
Regards,

Anthony Liguori

  reply	other threads:[~2009-04-22 18:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22  2:17 [Qemu-devel] PATCH: enabling TCP keepalives on VNC connections David S. Ahern
2009-04-22 18:26 ` Anthony Liguori [this message]
2009-04-22 21:22   ` David S. Ahern
  -- strict thread matches above, loose matches on Subject: below --
2009-04-22  1:48 David Ahern
2009-04-22  1:46 David Ahern
2009-04-21 20:06 David Ahern
2009-04-21 19:21 David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49EF614B.9000601@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=daahern@cisco.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).