diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-03-12 16:08:27 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-03-12 16:08:27 +0100 |
commit | e0992467867e4832b3333fb0cb5a638d05250bd3 (patch) | |
tree | 09f28bdf055e681ab75e2f04b03c4c864d5373d5 | |
parent | 8d80d831227cc0d74a90c210e40e17bd6394f4d2 (diff) | |
download | dabmod-e0992467867e4832b3333fb0cb5a638d05250bd3.tar.gz dabmod-e0992467867e4832b3333fb0cb5a638d05250bd3.tar.bz2 dabmod-e0992467867e4832b3333fb0cb5a638d05250bd3.zip |
RC: avoid zmq RC crash on 'show' of non-existing controllable
-rw-r--r-- | src/RemoteControl.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp index 808153a..1065456 100644 --- a/src/RemoteControl.cpp +++ b/src/RemoteControl.cpp @@ -523,16 +523,21 @@ void RemoteControllerZmq::process() } else if (msg.size() == 2 && command == "show") { std::string module((char*) msg[1].data(), msg[1].size()); - list< vector<string> > r = rcs.get_param_list_values(module); - size_t r_size = r.size(); - for (auto ¶m_val : r) { - std::stringstream ss; - ss << param_val[0] << ": " << param_val[1] << endl; - zmq::message_t zmsg(ss.str().size()); - memcpy(zmsg.data(), ss.str().data(), ss.str().size()); - - int flag = (--r_size > 0) ? ZMQ_SNDMORE : 0; - repSocket.send(zmsg, flag); + try { + list< vector<string> > r = rcs.get_param_list_values(module); + size_t r_size = r.size(); + for (auto ¶m_val : r) { + std::stringstream ss; + ss << param_val[0] << ": " << param_val[1] << endl; + zmq::message_t zmsg(ss.str().size()); + memcpy(zmsg.data(), ss.str().data(), ss.str().size()); + + int flag = (--r_size > 0) ? ZMQ_SNDMORE : 0; + repSocket.send(zmsg, flag); + } + } + catch (const ParameterError &err) { + send_fail_reply(repSocket, err.what()); } } else if (msg.size() == 3 && command == "get") { |