Merge pull request #821 from hallyn/2016-02-15/lognull

2016 02 15/lognull
This commit is contained in:
Christian Brauner 2016-02-15 21:38:00 +01:00
commit ae07a9bfda

View File

@ -20,6 +20,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include <limits.h>
@ -252,6 +253,16 @@ static char *build_log_path(const char *name, const char *lxcpath)
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
@ -264,11 +275,12 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
{
if (lxc_log_fd != -1) {
// we are overriding the default.
close(lxc_log_fd);
free(log_fname);
lxc_log_close();
}
if (!fname || strlen(fname) == 0) {
assert(fname != NULL);
if (strlen(fname) == 0) {
log_fname = NULL;
return 0;
}
@ -380,16 +392,6 @@ extern int lxc_log_init(const char *name, const char *file,
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