On Fri, Mar 10, 2017 at 08:46:09AM -0500, Frediano Ziglio wrote: > > > > This allows to move some low-level code out of reds.c > > > > Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx> > > --- > > server/net-utils.c | 25 +++++++++++++++++++++++++ > > server/net-utils.h | 1 + > > server/reds.c | 27 ++------------------------- > > 3 files changed, 28 insertions(+), 25 deletions(-) > > > > diff --git a/server/net-utils.c b/server/net-utils.c > > index ce409be..995b0d4 100644 > > --- a/server/net-utils.c > > +++ b/server/net-utils.c > > @@ -31,6 +31,31 @@ > > > > #include "net-utils.h" > > > > +bool red_socket_set_keepalive(int fd, bool enable, int timeout) > > +{ > > + int keepalive = !!enable; > > + > > + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, > > sizeof(keepalive)) == -1) { > > + if (errno != ENOTSUP) { > > + spice_printerr("setsockopt for keepalive failed, %s", > > strerror(errno)); > > + return false; > > + } > > + } > > + > > + if (!enable) { > > + return true; > > + } > > + > > + if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == > > -1) { > > About this value. NetBSD, Windows and Mac use milliseconds. This is not true for NetBSD and Mac: http://www.unix.com/man-page/netbsd/4/tcp/ "The TCP_KEEPIDLE option can be used to affect this value for a given socket, and specifies the number of seconds of idle time between keepalive probes." For Mac, I only found https://stackoverflow.com/questions/15860127/how-to-configure-tcp-keepalive-under-mac-os-x but this uses values in seconds. Christophe
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel