From: Tycho Andersen Date: Wed, 2 Dec 2015 21:30:52 +0000 (-0700) Subject: api wrapper: only reset the current config if this call set it X-Git-Tag: lxc-2.0.0.beta1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8164f0e253e9c148a3c3c09eec5e0ebe56602805;p=thirdparty%2Flxc.git api wrapper: only reset the current config if this call set it Instead of *always* resetting the current_config to null, we should only reset it if this API call set it. This allows nesting of API calls, e.g. c->checkpoint() can pass stuff into criu.c, which can call c->init_pid() and not lose the ability to log stuff afterwards. Signed-off-by: Tycho Andersen Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 280484189..bc5d58514 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -345,9 +345,17 @@ out: static rettype fnname(struct lxc_container *c) \ { \ rettype ret; \ - current_config = c ? c->lxc_conf : NULL; \ + bool reset_config = false; \ + \ + if (!current_config && c && c->lxc_conf) { \ + current_config = c->lxc_conf; \ + reset_config = true; \ + } \ + \ ret = do_##fnname(c); \ - current_config = NULL; \ + if (reset_config) \ + current_config = NULL; \ + \ return ret; \ } @@ -355,9 +363,17 @@ static rettype fnname(struct lxc_container *c) \ static rettype fnname(struct lxc_container *c, t1 a1) \ { \ rettype ret; \ - current_config = c ? c->lxc_conf : NULL; \ + bool reset_config = false; \ + \ + if (!current_config && c && c->lxc_conf) { \ + current_config = c->lxc_conf; \ + reset_config = true; \ + } \ + \ ret = do_##fnname(c, a1); \ - current_config = NULL; \ + if (reset_config) \ + current_config = NULL; \ + \ return ret; \ } @@ -365,9 +381,17 @@ static rettype fnname(struct lxc_container *c, t1 a1) \ static rettype fnname(struct lxc_container *c, t1 a1, t2 a2) \ { \ rettype ret; \ - current_config = c ? c->lxc_conf : NULL; \ + bool reset_config = false; \ + \ + if (!current_config && c && c->lxc_conf) { \ + current_config = c->lxc_conf; \ + reset_config = true; \ + } \ + \ ret = do_##fnname(c, a1, a2); \ - current_config = NULL; \ + if (reset_config) \ + current_config = NULL; \ + \ return ret; \ } @@ -375,9 +399,17 @@ static rettype fnname(struct lxc_container *c, t1 a1, t2 a2) \ static rettype fnname(struct lxc_container *c, t1 a1, t2 a2, t3 a3) \ { \ rettype ret; \ - current_config = c ? c->lxc_conf : NULL; \ + bool reset_config = false; \ + \ + if (!current_config && c && c->lxc_conf) { \ + current_config = c->lxc_conf; \ + reset_config = true; \ + } \ + \ ret = do_##fnname(c, a1, a2, a3); \ - current_config = NULL; \ + if (reset_config) \ + current_config = NULL; \ + \ return ret; \ }