Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use distinct names for file and program output pointers. #335

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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