summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-11-09 08:13:17 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-11-09 08:13:17 +0000
commit0b15f62c76aa16238ea120fb5a5a77c6d2dc1c61 (patch)
tree951d3fb5c8be81a9f0b835757e4958968ebf96c9
parentfixed get_readables (signal fd was not added) (diff)
fixed client and module remove
added disable command to debug shell git-svn-id: https://svn.spreadspace.org/gcsd/trunk@16 ac14a137-c7f1-4531-abe0-07747231d213
-rw-r--r--src/main_loop.lua4
-rw-r--r--src/module_list.lua12
-rw-r--r--src/modules/debug_shell.lua4
3 files changed, 18 insertions, 2 deletions
diff --git a/src/main_loop.lua b/src/main_loop.lua
index 0679d92..6b0e912 100644
--- a/src/main_loop.lua
+++ b/src/main_loop.lua
@@ -92,9 +92,9 @@ function main_loop(opt)
-- TODO: remove all modules of same type as this and
-- unload module
elseif(ret == defines.KILL_MODULE) then
- input.client_instance.module_instance:cleanup()
+ module_list:unregister(input.client_instance.module_instance)
elseif(ret == defines.KILL_CLIENT) then
- input.client_instance:cleanup()
+ client_list:unregister(input.client_instance)
end
end
end
diff --git a/src/module_list.lua b/src/module_list.lua
index 4a706cc..a41b15e 100644
--- a/src/module_list.lua
+++ b/src/module_list.lua
@@ -56,8 +56,20 @@ function module_list:init(opt)
end
end
+function module_list:unregister(module)
+ for i, m in ipairs(self.modules) do
+ if(m == module) then
+ log.printf(log.INFO, "removing module: " .. module.name)
+ module:cleanup()
+ table.remove(self.modules, i)
+ break
+ end
+ end
+end
+
function module_list:cleanup()
for _, module in ipairs(self.modules) do
+ log.printf(log.INFO, "removing module: " .. module.name)
module:cleanup()
end
end
diff --git a/src/modules/debug_shell.lua b/src/modules/debug_shell.lua
index 6e0ad73..147fc54 100644
--- a/src/modules/debug_shell.lua
+++ b/src/modules/debug_shell.lua
@@ -198,6 +198,10 @@ function debug_shell:exec_cmd(socket)
if(sep and sep ~= "") then socket.out_buffer = socket.out_buffer .. "unknown command\n" end
log.printf(log.INFO, "debug shell: quitting debug session")
ret = defines.KILL_CLIENT
+ elseif(cmd == 'disable') then
+ if(sep and sep ~= "") then socket.out_buffer = socket.out_buffer .. "unknown command\n" end
+ log.printf(log.NOTICE, "debug shell: disabling debug shell and close all connections")
+ ret = defines.KILL_MODULE
elseif(cmd == 'terminate') then
if(sep and sep ~= "") then socket.out_buffer = socket.out_buffer .. "unknown command\n" end
log.printf(log.NOTICE, "debug shell: terminate command received")