From 3c1a97f45007211acc0913ec5410158dc1414a98 Mon Sep 17 00:00:00 2001 From: faluco Date: Thu, 25 Mar 2021 10:38:00 +0100 Subject: [PATCH] - Use fprintf in the srsran_assert context incase the assert is being triggered by srslog producing a circular loop. - Switch to use a dynamic circular buffer for the log backend queue. --- lib/include/srsran/common/srsran_assert.h | 3 ++- lib/include/srsran/srslog/detail/support/work_queue.h | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h index fc30241fc..77094ac0f 100644 --- a/lib/include/srsran/common/srsran_assert.h +++ b/lib/include/srsran/common/srsran_assert.h @@ -13,8 +13,8 @@ #ifndef SRSRAN_ASSERT_H #define SRSRAN_ASSERT_H -#include "srsran/common/standard_streams.h" #include "srsran/srslog/srslog.h" +#include #ifdef ASSERTS_ENABLED @@ -27,6 +27,7 @@ #define srsran_assert(condition, fmt, ...) \ do { \ if (srsran_unlikely(not(condition))) { \ + std::fprintf(stderr, "%s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ std::abort(); \ } \ } while (0) diff --git a/lib/include/srsran/srslog/detail/support/work_queue.h b/lib/include/srsran/srslog/detail/support/work_queue.h index ef7b9d8de..2a7f17b20 100644 --- a/lib/include/srsran/srslog/detail/support/work_queue.h +++ b/lib/include/srsran/srslog/detail/support/work_queue.h @@ -27,12 +27,12 @@ namespace detail { template class work_queue { - srsran::static_circular_buffer queue; - mutable condition_variable cond_var; - static constexpr size_t threshold = capacity * 0.98; + srsran::dyn_circular_buffer queue; + mutable condition_variable cond_var; + static constexpr size_t threshold = capacity * 0.98; public: - work_queue() = default; + work_queue() : queue(capacity) {} work_queue(const work_queue&) = delete; work_queue& operator=(const work_queue&) = delete;