[lxc-devel] [go-lxc/v2] Avoid race on garbage collection
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Sep 21 12:39:13 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 356 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180921/d228c9dd/attachment.bin>
-------------- next part --------------
From 3b659cf54f1c72959c6f55f0569e7ac3e451d9e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 21 Sep 2018 14:37:53 +0200
Subject: [PATCH] Avoid race on garbage collection
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxc-binding.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lxc-binding.go b/lxc-binding.go
index a29d807..01e04fc 100644
--- a/lxc-binding.go
+++ b/lxc-binding.go
@@ -59,6 +59,9 @@ func Release(c *Container) bool {
// http://golang.org/pkg/runtime/#SetFinalizer
runtime.SetFinalizer(c, nil)
+ // Go is bad at refcounting sometimes
+ c.mu.Lock()
+
return C.lxc_container_put(c.container) == 1
}
More information about the lxc-devel
mailing list