diff options
author | Steven Koo <steven.koo@ni.com> | 2020-12-18 16:11:57 -0600 |
---|---|---|
committer | michael-west <michael.west@ettus.com> | 2020-12-21 09:37:17 -0800 |
commit | daa7ea5913bcbe2c63715eaab18b8c8f26608608 (patch) | |
tree | 4e2dee8881f2d9d1d09c91b7fcaa6ef5381cd9b3 /host/lib | |
parent | 0ffc594196a9f5b9fac3858e17eb858bbc2bd444 (diff) | |
download | uhd-daa7ea5913bcbe2c63715eaab18b8c8f26608608.tar.gz uhd-daa7ea5913bcbe2c63715eaab18b8c8f26608608.tar.bz2 uhd-daa7ea5913bcbe2c63715eaab18b8c8f26608608.zip |
usrprio: catch exceptions if rpc data read fails
This is an unhandled exception case that can cause silent failures for
detecting ethernet x310 devices if the niusrpriorpc service is enabled.
The "out_args >> vtr_size" read can throw an exception if there are no
PCIe devices connected.
Signed-off-by: Steven Koo <steven.koo@ni.com>
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/transport/nirio/rpc/usrprio_rpc_client.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/host/lib/transport/nirio/rpc/usrprio_rpc_client.cpp b/host/lib/transport/nirio/rpc/usrprio_rpc_client.cpp index 718ff7c05..116232def 100644 --- a/host/lib/transport/nirio/rpc/usrprio_rpc_client.cpp +++ b/host/lib/transport/nirio/rpc/usrprio_rpc_client.cpp @@ -40,14 +40,28 @@ nirio_status usrprio_rpc_client::niusrprio_enumerate(NIUSRPRIO_ENUMERATE_ARGS) _rpc_client.call(NIUSRPRIO_ENUMERATE, in_args, out_args, _timeout)); if (nirio_status_not_fatal(status)) { - out_args >> status; - out_args >> vtr_size; + try { + out_args >> status; + out_args >> vtr_size; + } catch (std::exception&) { + if (status == NiRio_Status_Success) { + status = NiRio_Status_RpcSessionError; + } + return status; + } } if (nirio_status_not_fatal(status) && vtr_size > 0) { device_info_vtr.resize(vtr_size); for (size_t i = 0; i < (size_t)vtr_size; i++) { usrprio_device_info info; - out_args >> info; + try { + out_args >> info; + } catch (std::exception&) { + if (status == NiRio_Status_Success) { + status = NiRio_Status_RpcSessionError; + } + return status; + } device_info_vtr[i] = info; } } |