diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-05-13 12:12:37 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-05-23 17:13:40 -0700 |
commit | 056dabcaf37469d0e614d269ded3e6e4c41d4cc8 (patch) | |
tree | 874722d1b2a5a8218034776089eb4c04fe412f04 /host/lib/utils/log.cpp | |
parent | b431866a5ec00753b40823e3172a8388582701c4 (diff) | |
download | uhd-056dabcaf37469d0e614d269ded3e6e4c41d4cc8.tar.gz uhd-056dabcaf37469d0e614d269ded3e6e4c41d4cc8.tar.bz2 uhd-056dabcaf37469d0e614d269ded3e6e4c41d4cc8.zip |
log: Removed timeout from logger, replaced with wait.
This works because there's also another trace message on termination of
the logger.
Diffstat (limited to 'host/lib/utils/log.cpp')
-rw-r--r-- | host/lib/utils/log.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 3bed85af7..6a694ed8e 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -258,6 +258,22 @@ public: ~log_resource(void){ _exit = true; + // We push a final message to kick the pop task out of it's wait state. + // This wouldn't be necessary if pop_with_wait() could fail. Should + // that ever get fixed, we can remove this. + auto final_message = uhd::log::logging_info( + pt::microsec_clock::local_time(), + uhd::log::trace, + __FILE__, + __LINE__, + "LOGGING", + boost::this_thread::get_id() + ); + final_message.message = "Terminating logger."; + push(final_message); +#ifndef UHD_LOG_FASTPATH_DISABLE + push_fastpath(""); +#endif _pop_task->join(); { std::lock_guard<std::mutex> l(_logmap_mutex); @@ -291,7 +307,8 @@ public: log_info.message = ""; while (!_exit) { - if (_log_queue.pop_with_timed_wait(log_info, 1)){ + _log_queue.pop_with_wait(log_info); + { std::lock_guard<std::mutex> l(_logmap_mutex); for (const auto &logger : _loggers) { auto level = logger_level.find(logger.first); @@ -321,7 +338,8 @@ public: #ifndef UHD_LOG_FASTPATH_DISABLE while (!_exit) { std::string msg; - if (_fastpath_queue.pop_with_timed_wait(msg, 1)){ + _fastpath_queue.pop_with_wait(msg); + { std::cerr << msg << std::flush; } } |