The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5966

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
To avoid race on task end.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From ef74ab3e6ea9a635074d687d31cbdf29bc9a7c63 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@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.parr...@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)
        }
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to