Commit 8164f0e2 by Tycho Andersen Committed by Stéphane Graber

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: 's avatarTycho Andersen <tycho.andersen@canonical.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 23820d54
......@@ -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; \
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment