diff options
author | Vasil Velichkov <vvvelichkov@gmail.com> | 2020-02-20 03:10:38 +0200 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2020-03-10 10:54:30 -0400 |
commit | ff9b489dee9293e1837910990bd2f2b60f5e7fde (patch) | |
tree | 994df48b078b5b51aae38c1527dee9046d77d1a5 /gr-zeromq/lib/req_msg_source_impl.cc | |
parent | 3154f78425bb86934c19a99d21ed965ae6d2410d (diff) |
zmq: Handle the PMT exceptions
Handle the PMT exceptions when deserializing the received ZMQ messages,
log an error message and continue the execution.
Previously the unhandled exceptions were aborting the process:
terminate called after throwing an instance of 'pmt::exception'
what(): pmt::deserialize: malformed input stream, tag value = : 50
Aborted (core dumped)
Diffstat (limited to 'gr-zeromq/lib/req_msg_source_impl.cc')
-rw-r--r-- | gr-zeromq/lib/req_msg_source_impl.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gr-zeromq/lib/req_msg_source_impl.cc b/gr-zeromq/lib/req_msg_source_impl.cc index c246e3a57c..0118b4d084 100644 --- a/gr-zeromq/lib/req_msg_source_impl.cc +++ b/gr-zeromq/lib/req_msg_source_impl.cc @@ -109,8 +109,12 @@ void req_msg_source_impl::readloop() std::string buf(static_cast<char*>(msg.data()), msg.size()); std::stringbuf sb(buf); - pmt::pmt_t m = pmt::deserialize(sb); - message_port_pub(d_port, m); + try { + pmt::pmt_t m = pmt::deserialize(sb); + message_port_pub(d_port, m); + } catch (pmt::exception& e) { + GR_LOG_ERROR(d_logger, std::string("Invalid PMT message: ") + e.what()); + } } else { boost::this_thread::sleep(boost::posix_time::microseconds(100)); |