[lxc-devel] [lxd/master] config: set it in daemonConfig before calling the setters
tych0 on Github
lxc-bot at linuxcontainers.org
Wed Apr 27 17:03:21 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 451 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160427/72796fca/attachment.bin>
-------------- next part --------------
From a2bc518091aebb56a60390840c822ba18102c8e8 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Wed, 27 Apr 2016 10:56:26 -0600
Subject: [PATCH] config: set it in daemonConfig before calling the setters
some setters inspect this value, let's set it in daemonConfig so they don't
screw up.
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
lxd/daemon_config.go | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lxd/daemon_config.go b/lxd/daemon_config.go
index e9ff6a5..991d644 100644
--- a/lxd/daemon_config.go
+++ b/lxd/daemon_config.go
@@ -98,13 +98,20 @@ func (k *daemonConfigKey) Set(d *Daemon, value string) error {
return err
}
+ // Actually apply the change
+ name = k.name()
+ daemonConfigLock.Lock()
+ k.currentValue = value
// Run external setting function
if k.setter != nil {
- value, err = k.setter(d, k.name(), value)
+ value, err = k.setter(d, name, value)
if err != nil {
+ k.currentValue = oldValue
+ daemonConfigLock.Unlock()
return err
}
}
+ daemonConfigLock.Unlock()
// Get the configuration key and make sure daemonConfig is sane
name = k.name()
@@ -112,11 +119,6 @@ func (k *daemonConfigKey) Set(d *Daemon, value string) error {
return fmt.Errorf("Corrupted configuration cache")
}
- // Actually apply the change
- daemonConfigLock.Lock()
- k.currentValue = value
- daemonConfigLock.Unlock()
-
err = dbConfigValueSet(d.db, name, value)
if err != nil {
return err
More information about the lxc-devel
mailing list