]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix fd leak in lxc log
authorDwight Engen <dwight.engen@oracle.com>
Mon, 26 Nov 2012 17:17:51 +0000 (12:17 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 26 Nov 2012 17:53:57 +0000 (12:53 -0500)
lxc_log_init will leak an fd when it is called by a long running
program that may call lxc_container_new multiple times. Fix by
only opening the log if it is not already open.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/log.c

index 7f3b6b25bef50d5163d067817e9c272f9b590aff..02ee21cfeea2fd1a780d014267286a9b165e9aed 100644 (file)
@@ -153,6 +153,9 @@ extern int lxc_log_init(const char *file, const char *priority,
 {
        int lxc_priority = LXC_LOG_PRIORITY_ERROR;
 
+       if (lxc_log_fd != -1)
+               return 0;
+
        if (priority) {
                lxc_priority = lxc_log_priority_to_int(priority);