summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-05-10 08:55:01 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2012-05-10 08:55:01 +0200
commit33bfd025958e4485f4647d22fb9aec5d7d94db81 (patch)
tree3c9e3e2dfc1651ebd5c2e5895ab2825b39d948b1
parentc5fb4fd4d89086399762ac844b53564d98ff2d4e (diff)
Ignore remove/move/update commands on protected taskids (root, Finished, etc...)
-rw-r--r--TODO2
-rw-r--r--src/muniacli.cc2
-rw-r--r--src/taskmanager.cc13
3 files changed, 15 insertions, 2 deletions
diff --git a/TODO b/TODO
index 200a30e..8b13789 100644
--- a/TODO
+++ b/TODO
@@ -1 +1 @@
-Server segfaults on 'remove 0'
+
diff --git a/src/muniacli.cc b/src/muniacli.cc
index 3620a85..a84de65 100644
--- a/src/muniacli.cc
+++ b/src/muniacli.cc
@@ -34,7 +34,7 @@
#include <libwebsockets.h>
enum demo_protocols {
- PROTOCOL_TASK,
+ PROTOCOL_TASK
};
static int callback_task(struct libwebsocket_context *me,
diff --git a/src/taskmanager.cc b/src/taskmanager.cc
index b50e9a6..87cf2b0 100644
--- a/src/taskmanager.cc
+++ b/src/taskmanager.cc
@@ -39,6 +39,11 @@ TaskManager task_manager;
#define PROJECTS_ID 4
#define FIRST_TASK_ID 10
+static bool isProtected(taskid_t id)
+{
+ return id < FIRST_TASK_ID;
+}
+
TaskManager::TaskManager() {
idCount = FIRST_TASK_ID;
@@ -79,6 +84,9 @@ taskid_t TaskManager::createId() {
TaskIdList TaskManager::moveTask(taskid_t id, taskid_t to)
throw (std::exception) {
+
+ if(isProtected(id)) return TaskIdList();
+
TaskIdList affectedTasks;
try {
@@ -93,6 +101,9 @@ TaskIdList TaskManager::moveTask(taskid_t id, taskid_t to)
TaskIdList TaskManager::removeTask(taskid_t id)
throw (std::exception) {
+
+ if(isProtected(id)) return TaskIdList();
+
TaskIdList affectedTasks;
if(tree.bfs(id).size() > 1) throw std::exception();
@@ -110,6 +121,8 @@ TaskIdList TaskManager::removeTask(taskid_t id)
TaskIdList TaskManager::updateTask(taskid_t id, task_t t)
throw (std::exception) {
+ if(isProtected(id)) return TaskIdList();
+
TaskIdList affectedTasks;
try {