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

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) ===
some setters inspect this value, let's set it in daemonConfig so they don't
screw up.

Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
From a2bc518091aebb56a60390840c822ba18102c8e8 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.ander...@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.ander...@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
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to