[lxc-devel] [lxd/master] task/group: Moves wait group Done() after g.running update
tomponline on Github
lxc-bot at linuxcontainers.org
Tue Jul 16 12:36:10 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 391 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190716/26433bdb/attachment.bin>
-------------- next part --------------
From ef74ab3e6ea9a635074d687d31cbdf29bc9a7c63 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Tue, 16 Jul 2019 13:35:04 +0100
Subject: [PATCH] task/group: Moves wait group Done() after g.running update to
avoid race on task end
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/task/group.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lxd/task/group.go b/lxd/task/group.go
index ac086bb28d..d40c257225 100644
--- a/lxd/task/group.go
+++ b/lxd/task/group.go
@@ -59,11 +59,13 @@ func (g *Group) Start() {
go func(i int) {
task.loop(ctx)
- g.wg.Done()
+ // Ensure running map is updated before wait group Done() is called.
g.mu.Lock()
g.running[i] = false
g.mu.Unlock()
+
+ g.wg.Done()
}(i)
}
}
More information about the lxc-devel
mailing list