From d48da81bc4226f0d65274bdf7b832b8cff365431 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 31 May 2010 00:47:53 +0000 Subject: small bugfixes --- src/debug_shell.lua | 15 ++++++++------- 1 file 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("! execute lua code\n" .. "quit quit this debug session\n" .. "ping[ ] echo request (response will be 'pong[ ]')\n" .. -- cgit v1.2.3