summaryrefslogtreecommitdiff
path: root/src/modules/stdout.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/stdout.lua')
-rw-r--r--src/modules/stdout.lua25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/modules/stdout.lua b/src/modules/stdout.lua
index c88812d..c82aa1f 100644
--- a/src/modules/stdout.lua
+++ b/src/modules/stdout.lua
@@ -34,8 +34,7 @@ local defines = require("defines")
-- stdout module class
local stdout = {}
-stdout.properties = { type=defines.OUT_MODULE, name="stdout", max_instances=-1 }
-stdout.next_id = 0
+stdout.properties = { type=defines.OUT_MODULE, name="stdout", max_instances=1 }
-- create new instance of stdout module class
function stdout:new(config)
@@ -43,25 +42,33 @@ function stdout:new(config)
inst.class = self.properties.name
inst.config = config
if(config.name == nil or config.name == "") then
- inst.name = self.properties.name .. self.next_id
- self.next_id = self.next_id + 1
+ inst.name = self.properties.name
else
inst.name = config.name
end
+
local handle = {}
handle.fd = 1
+ rawio.setnonblock(handle.fd)
handle.client_instance = nil
handle.out_buffer = nil
function handle:getfd() return self.fd end
function handle:dirty() return 0 end
function handle:read() end
function handle:write()
- io.stdout:write(self.out_buffer)
- io.stdout:flush()
- self.out_buffer = nil
- command_queue:command_sent()
- command_queue:command_completed()
+ local len, err = rawio.write(1, self.out_buffer)
+ if(len == nil) then
+ log.printf(log.INFO, inst.name .. ": connection error: %s", err)
+ ret = defines.KILL_MODULE_CLASS
+ else
+ self.out_buffer = string.sub(self.out_buffer, len+1)
+ end
+ if(self.out_buffer == "") then
+ command_queue:command_sent()
+ command_queue:command_completed()
+ end
+ return defines.OK
end
local client = {}