Otherwise after a shortcut on error we could end up trying to write
to the closed log fd.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
return p;
}
+extern void lxc_log_close(void)
+{
+ if (lxc_log_fd == -1)
+ return;
+ close(lxc_log_fd);
+ lxc_log_fd = -1;
+ free(log_fname);
+ log_fname = NULL;
+}
+
/*
* This can be called:
* 1. when a program calls lxc_log_init with no logfile parameter (in which
{
if (lxc_log_fd != -1) {
// we are overriding the default.
- close(lxc_log_fd);
- free(log_fname);
+ lxc_log_close();
}
assert(fname != NULL);
return ret;
}
-extern void lxc_log_close(void)
-{
- if (lxc_log_fd == -1)
- return;
- close(lxc_log_fd);
- lxc_log_fd = -1;
- free(log_fname);
- log_fname = NULL;
-}
-
/*
* This is called when we read a lxc.loglevel entry in a lxc.conf file. This
* happens after processing command line arguments, which override the .conf