[lxc-devel] [lxd/master] Enable tcp KeepAlive

Catramen on Github lxc-bot at linuxcontainers.org
Mon Jun 18 16:45:57 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 379 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180618/978bca03/attachment.bin>
-------------- next part --------------
From 31e017c10f1a62347e12456ed16d60d662eacdc6 Mon Sep 17 00:00:00 2001
From: Jingkui Wang <jkwang at google.com>
Date: Mon, 18 Jun 2018 09:44:22 -0700
Subject: [PATCH] Enable tcp KeepAlive

This will stop lxc from block indefinitely when there is network change.
---
 shared/network.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/shared/network.go b/shared/network.go
index 2ccb7dc8c..f47f75cea 100644
--- a/shared/network.go
+++ b/shared/network.go
@@ -31,6 +31,10 @@ func RFC3493Dialer(network, address string) (net.Conn, error) {
 		if err != nil {
 			continue
 		}
+		if tc, ok := c.(*net.TCPConn); ok {
+			tc.SetKeepAlive(true)
+			tc.SetKeepAlivePeriod(3 * time.Second)
+		}
 		return c, err
 	}
 	return nil, fmt.Errorf("Unable to connect to: " + address)


More information about the lxc-devel mailing list