diff options
Diffstat (limited to 'src/main_loop.lua')
-rw-r--r-- | src/main_loop.lua | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main_loop.lua b/src/main_loop.lua index f7f09e9..cb74170 100644 --- a/src/main_loop.lua +++ b/src/main_loop.lua @@ -35,16 +35,12 @@ function main_loop(opt) log.printf(log.NOTICE, "main_loop started") local sig = signal.init() - local sock = {} - sock[1] = echo_server.init("localhost", 9000) - if(sock[1] == nil) then return -1 end - - sock[2] = echo_server.init("localhost", 10000) - if(sock[2] == nil) then return -1 end + local ret = debug_shell.init("localhost", 9000) + if(ret == nil) then return -1 end local return_value = 0 while return_value == 0 do - local readable, _, err = socket.select({ sig , sock[1], sock[2] }, nil) + local readable, _, err = socket.select({ sig , unpack(debug_shell.socks) } , nil) if(err) then log.printf(log.ERROR, "select returned with error: %s", err) return_value = -1 @@ -53,9 +49,11 @@ function main_loop(opt) if(input == sig) then return_value = signal.handle() if(return_value == 1) then break end - else - return_value = echo_server.handle(input) + elseif(input == debug_shell.socks[1] or input == debug_shell.socks[2]) then + return_value = debug_shell.handle(input) if(return_value == 2) then break end + else + log.printf(log.ERROR, "select returned unknown file descriptor!?") end end end @@ -63,6 +61,7 @@ function main_loop(opt) if(return_value == 2) then return_value = 0 end + debug_shell.close(); signal.stop() return return_value end |