summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-12-29 03:24:51 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-12-29 03:24:51 +0000
commita0ec02fc3b1b59fca03839cab6b029f849885184 (patch)
tree5f7389482f7fa5bcc45cc48259d76ba0656b5868
parentremoved trailing whitespaces (diff)
fixed build (copy paste error)
closing daemon when output module is supposed to be removed git-svn-id: https://svn.spreadspace.org/gcsd/trunk@88 ac14a137-c7f1-4531-abe0-07747231d213
-rw-r--r--TODO1
-rw-r--r--src/log.h2
-rw-r--r--src/main_loop.lua26
-rw-r--r--src/module_list.lua13
4 files changed, 26 insertions, 16 deletions
diff --git a/TODO b/TODO
index 3c1401e..3eb41dd 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
- * stop daemon when output module is supposed to be removed
* send response to requestor
* out-of-order responses
* add listener tables (for requests, responses and other messages)
diff --git a/src/log.h b/src/log.h
index a56db9f..504d141 100644
--- a/src/log.h
+++ b/src/log.h
@@ -1,4 +1,4 @@
-Installation/*
+/*
* gcsd
*
* gcsd the generic command sequencer daemon can be used to serialize
diff --git a/src/main_loop.lua b/src/main_loop.lua
index 46cb0b1..e92c9b7 100644
--- a/src/main_loop.lua
+++ b/src/main_loop.lua
@@ -110,30 +110,32 @@ function main_loop(opt)
if(return_value == 1) then break end
else
local ret = reader:read()
- if(ret == defines.KILL_DAEMON) then
- return_value = 2
- break
- elseif(ret == defines.KILL_MODULE_CLASS) then
- module_list:unregister_by_class(reader.client_instance.module_instance.class)
+ if(ret == defines.KILL_MODULE_CLASS) then
+ ret = module_list:unregister_by_class(reader.client_instance.module_instance.class)
elseif(ret == defines.KILL_MODULE) then
- module_list:unregister(reader.client_instance.module_instance)
+ ret = module_list:unregister(reader.client_instance.module_instance)
elseif(ret == defines.KILL_CLIENT) then
client_list:unregister(reader.client_instance)
end
+ if(ret == defines.KILL_DAEMON) then
+ return_value = 2
+ break
+ end
end
end
for _, writer in ipairs(writeable) do
ret = writer:write()
- if(ret == defines.KILL_DAEMON) then
- return_value = 2
- break
- elseif(ret == defines.KILL_MODULE_CLASS) then
- module_list:unregister_by_class(writer.client_instance.module_instance.class)
+ if(ret == defines.KILL_MODULE_CLASS) then
+ ret = module_list:unregister_by_class(writer.client_instance.module_instance.class)
elseif(ret == defines.KILL_MODULE) then
- module_list:unregister(writer.client_instance.module_instance)
+ ret = module_list:unregister(writer.client_instance.module_instance)
elseif(ret == defines.KILL_CLIENT) then
client_list:unregister(writer.client_instance)
end
+ if(ret == defines.KILL_DAEMON) then
+ return_value = 2
+ break
+ end
end
end
command_queue:check_timeout()
diff --git a/src/module_list.lua b/src/module_list.lua
index e343cf1..85428e4 100644
--- a/src/module_list.lua
+++ b/src/module_list.lua
@@ -119,8 +119,8 @@ end
function module_list:unregister(module)
if(module == self.output) then
- log.printf(log.WARNING, "won't remove output module: " .. module.name)
- return
+ log.printf(log.WARNING, "output module can't be removed safely, closing daemon")
+ return defines.KILL_DAEMON
end
for i, m in ipairs(self.inputs) do
@@ -131,11 +131,18 @@ function module_list:unregister(module)
break
end
end
+
+ return defines.OK
end
function module_list:unregister_by_class(class)
local free_list = {}
+ if(self.output.class == class) then
+ log.printf(log.WARNING, "output module can't be removed safely, closing daemon")
+ return defines.KILL_DAEMON
+ end
+
for i, m in ipairs(self.inputs) do
if(m.class == class) then
table.insert(free_list, 1, i)
@@ -147,6 +154,8 @@ function module_list:unregister_by_class(class)
self.inputs[i]:cleanup()
table.remove(self.inputs, i)
end
+
+ return defines.OK
end
function module_list:cleanup()