diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-05-24 12:07:25 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-05-24 12:07:25 +0200 |
commit | 91ea36900f8363f6f94ed4c9dc7f07fbf19cad6a (patch) | |
tree | 8b9aad66a5f35bda84ee0bff2730f7454f4ec0fe | |
parent | 181210b62a721b300e7ffe64880e069a91575212 (diff) |
Fix crash on 'observe n' where n was not in the tree. Fix compile warnings.
-rw-r--r-- | src/messageparser.cc | 2 | ||||
-rw-r--r-- | src/munia_proto.cc | 22 | ||||
-rw-r--r-- | src/muniacli.cc | 8 |
3 files changed, 22 insertions, 10 deletions
diff --git a/src/messageparser.cc b/src/messageparser.cc index bfaa033..ea5e615 100644 --- a/src/messageparser.cc +++ b/src/messageparser.cc @@ -100,7 +100,7 @@ inline static void parse_into_msg_tokens(std::string& data, inline static void create_msg_list(MsgTokensList& msgTokensList, MessageList& msgList, bool clientmode) { - int origin = 0; + size_t origin = 0; if(clientmode) { origin = 1; } diff --git a/src/munia_proto.cc b/src/munia_proto.cc index 6f42c28..61017b0 100644 --- a/src/munia_proto.cc +++ b/src/munia_proto.cc @@ -33,6 +33,8 @@ #include <queue> #include <map> +#include "debug.h" + #include "task.h" #include "messageparser.h" #include "messagehandler.h" @@ -198,8 +200,14 @@ int callback_lws_task(struct libwebsocket_context * context, while(omi != omsgs.end()) { if(omi->cmd == cmd::observe) { - - TaskIdList ids = task_manager.subTasks(omi->observe.id); + TaskIdList ids; + try { + ids = task_manager.subTasks(omi->observe.id); + } catch(...) { + DEBUG(proto, "No such node %d\n", omi->observe.id); + omi++; + continue; + } TaskIdList::iterator id = ids.begin(); while(id != ids.end()) { task_t task = task_manager.task(*id); @@ -216,8 +224,14 @@ int callback_lws_task(struct libwebsocket_context * context, } } else if(omi->cmd == cmd::unobserve) { - - TaskIdList ids = task_manager.subTasks(omi->observe.id); + TaskIdList ids; + try { + ids = task_manager.subTasks(omi->observe.id); + } catch(...) { + DEBUG(proto, "No such node %d\n", omi->observe.id); + omi++; + continue; + } TaskIdList::reverse_iterator id = ids.rbegin(); while(id != ids.rend()) { task_t task = task_manager.task(*id); diff --git a/src/muniacli.cc b/src/muniacli.cc index 30e0ecf..f0e151d 100644 --- a/src/muniacli.cc +++ b/src/muniacli.cc @@ -88,7 +88,6 @@ static void pretty_print(std::string msgs) { MessageList list = parse_msg_client(msgs); std::string indent; - int prevtask = -1; std::list<int> childlist; @@ -251,7 +250,7 @@ static struct option options[] = { { NULL, 0, 0, 0 } }; -static char* USAGE= +static const char* USAGE= "Usage: muniacli [OPTION]... TASK COMMAND\n" "Commandline client to munia." "Options:\n" @@ -271,10 +270,7 @@ static char* USAGE= int main(int argc, char** argv) { int port = 7681; - struct libwebsocket_context *context; - int opts = 0; std::string host = "localhost"; - int optionscount = 0; std::string taskbyid; std::string taskbyname; cmd_t cmd = DEFAULT; @@ -355,6 +351,8 @@ int main(int argc, char** argv) case UPDATE: msgs = "update " + taskbyid + " " + cmd_opts; break; + case DEFAULT: + break; } /* |