Skip to content

Commit

Permalink
Use distinct names for file and program output pointers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarp committed Mar 12, 2018
1 parent eb4feed commit b13e807
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions userspace/falco/lua/output.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ end

function mod.file(priority, priority_num, buffered, msg, options)
if options.keep_alive == "true" then
if file == nil then
file = io.open(options.filename, "a+")
if buffered == 0 then
file:setvbuf 'no'
end
if ffile == nil then
ffile = io.open(options.filename, "a+")
if buffered == 0 then
ffile:setvbuf 'no'
end
end
else
file = io.open(options.filename, "a+")
ffile = io.open(options.filename, "a+")
end

file:write(msg, "\n")
ffile:write(msg, "\n")

if options.keep_alive == nil or
options.keep_alive ~= "true" then
file:close()
file = nil
options.keep_alive ~= "true" then
ffile:close()
ffile = nil
end
end

function mod.file_cleanup()
if file ~= nil then
file:flush()
file:close()
file = nil
if ffile ~= nil then
ffile:flush()
ffile:close()
ffile = nil
end
end

Expand All @@ -87,30 +87,30 @@ function mod.program(priority, priority_num, buffered, msg, options)

-- Note: options are all strings
if options.keep_alive == "true" then
if file == nil then
file = io.popen(options.program, "w")
if buffered == 0 then
file:setvbuf 'no'
end
if pfile == nil then
pfile = io.popen(options.program, "w")
if buffered == 0 then
pfile:setvbuf 'no'
end
end
else
file = io.popen(options.program, "w")
pfile = io.popen(options.program, "w")
end

file:write(msg, "\n")
pfile:write(msg, "\n")

if options.keep_alive == nil or
options.keep_alive ~= "true" then
file:close()
file = nil
options.keep_alive ~= "true" then
pfile:close()
pfile = nil
end
end

function mod.program_cleanup()
if file ~= nil then
file:flush()
file:close()
file = nil
if pfile ~= nil then
pfile:flush()
pfile:close()
pfile = nil
end
end

Expand Down

0 comments on commit b13e807

Please sign in to comment.