summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anylike.org>2010-05-31 00:47:53 +0000
committerChristian Pointner <equinox@anylike.org>2010-05-31 00:47:53 +0000
commitd48da81bc4226f0d65274bdf7b832b8cff365431 (patch)
tree270ebae5935c22c2e083eaca77b22d9db6b58c6d
parentadded help command to debug shell (diff)
small bugfixes
-rw-r--r--src/debug_shell.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/debug_shell.lua b/src/debug_shell.lua
index 489395a..25bc1ed 100644
--- a/src/debug_shell.lua
+++ b/src/debug_shell.lua
@@ -58,7 +58,7 @@ debug_shell.init = function(host, port)
local ret, err = debug_shell.socks[1]:listen()
if(ret == nil) then
- log.printf(log.ERROR, "debug shell: listen() failed: %s", ip, port, err)
+ log.printf(log.ERROR, "debug shell: listen() failed: %s", err)
return nil
end
@@ -80,7 +80,7 @@ debug_shell.handle = function(sock)
if(sock == debug_shell.socks[1]) then
local newclient, err = debug_shell.socks[1]:accept()
if(newclient == nil) then
- log.printf(log.ERROR, "debug shell: accept() failed: %s", newclient, err)
+ log.printf(log.ERROR, "debug shell: accept() failed: %s", err)
end
local ip, port = newclient:getpeername();
if(debug_shell.socks[2]) then
@@ -91,12 +91,13 @@ debug_shell.handle = function(sock)
debug_shell.socks[2] = newclient
debug_shell.socks[2]:settimeout(0);
debug_shell.socks[2]:setoption('tcp-nodelay', true);
+ debug_shell.buffer = "";
end
- else
+ else
local data, err, partial = debug_shell.socks[2]:receive('*l')
if(data == nil) then
if(err == 'closed') then
- log.printf(log.INFO, "debug shell: connection closed by peer", ip, port)
+ log.printf(log.INFO, "debug shell: connection closed by peer")
debug_shell.socks[2]:close()
debug_shell.socks[2] = nil
elseif(err == 'timeout') then
@@ -147,15 +148,15 @@ debug_shell.exec_cmd = function()
local cmd, sep, param = string.match(debug_shell.buffer, "^(%w+)(.?)(.*)$");
if(cmd == 'quit') then
- if(sep and sep ~= "") then return 0 end
+ if(sep and sep ~= "") then debug_shell.socks[2]:send("unknown command\n") end
log.printf(log.INFO, "debug shell: quitting debug session")
ret = 1
elseif(cmd == 'terminate') then
- if(sep and sep ~= "") then return 0 end
+ if(sep and sep ~= "") then debug_shell.socks[2]:send("unknown command\n") end
log.printf(log.NOTICE, "debug shell: terminate command received")
ret = 2
elseif(cmd == 'help') then
- if(sep and sep ~= "") then return 0 end
+ if(sep and sep ~= "") then debug_shell.socks[2]:send("unknown command\n") end
debug_shell.socks[2]:send("!<lua code> execute lua code\n" ..
"quit quit this debug session\n" ..
"ping[ <data>] echo request (response will be 'pong[ <data>]')\n" ..