[lxc-devel] [lxd/master] Unlock when isLeader failure

SimonRichardson on Github lxc-bot at linuxcontainers.org
Sun Feb 9 15:12:24 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 544 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200209/e7d782dd/attachment.bin>
-------------- next part --------------
From bfce70ebc0199bbaa9d997184736f3f2ec0fdb88 Mon Sep 17 00:00:00 2001
From: Simon Richardson <stickupkid at gmail.com>
Date: Sun, 9 Feb 2020 15:10:34 +0000
Subject: [PATCH] Unlock when isLeader failure

The following ensures that when requesting isLeader and an error is
returned, that the code correctly unlocks, otherwise you could end up
with a lockup.

I'm unsure how often this would happen, I found this just looking over
the codebase.
---
 lxd/cluster/gateway.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxd/cluster/gateway.go b/lxd/cluster/gateway.go
index 646e8f017a..7cda19b60c 100644
--- a/lxd/cluster/gateway.go
+++ b/lxd/cluster/gateway.go
@@ -700,6 +700,7 @@ func (g *Gateway) waitLeadership() error {
 		g.lock.RLock()
 		isLeader, err := g.isLeader()
 		if err != nil {
+			g.lock.RUnlock()
 			return err
 		}
 		if isLeader {


More information about the lxc-devel mailing list