From: Tobias Ulmer Date: Thu, 21 Dec 2017 19:30:56 +0000 (+0100) Subject: e2lib: don't close debuglogfile early, improve performance X-Git-Tag: e2factory-2.3.18rc1~86 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=eecedc236beca9b5ee69dd2c9c2a04bf8224a234;p=e2factory.git e2lib: don't close debuglogfile early, improve performance Signed-off-by: Tobias Ulmer --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index afa2204..0ce0ee7 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -618,10 +618,12 @@ function e2lib.log(level, msg, nonewline) if e2lib.globals.debuglogfile then -- write out buffered messages first - for _,m in ipairs(e2lib.globals.debuglogfilebuffer) do - eio.fwrite(e2lib.globals.debuglogfile, m) + if #e2lib.globals.debuglogfilebuffer > 0 then + for _,m in ipairs(e2lib.globals.debuglogfilebuffer) do + eio.fwrite(e2lib.globals.debuglogfile, m) + end + e2lib.globals.debuglogfilebuffer = {} end - e2lib.globals.debuglogfilebuffer = {} eio.fwrite(e2lib.globals.debuglogfile, log_prefix .. msg) else @@ -737,10 +739,6 @@ function e2lib.cleanup() if e2lib.globals.lock then e2lib.globals.lock:cleanup() end - - if e2lib.globals.debuglogfile then - eio.fclose(e2lib.globals.debuglogfile) - end end --- exit from the tool, cleaning up temporary files and directories @@ -751,8 +749,11 @@ function e2lib.finish(returncode) returncode = 0 end e2lib.cleanup() + + e2lib.logf(4, "exiting e2factory with returncode=%d", returncode) if e2lib.globals.debuglogfile then eio.fclose(e2lib.globals.debuglogfile) + e2lib.globals.debuglogfile = false end console.close() os.exit(returncode)