Add log to pool deallocate

master
Ismael Gomez 6 years ago
parent 3cb9f51460
commit 5474f6d55f

@ -38,6 +38,7 @@
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include "srslte/common/log.h"
#include "srslte/common/common.h" #include "srslte/common/common.h"
namespace srslte { namespace srslte {
@ -184,6 +185,7 @@ public:
static byte_buffer_pool* get_instance(int capacity = -1); static byte_buffer_pool* get_instance(int capacity = -1);
static void cleanup(void); static void cleanup(void);
byte_buffer_pool(int capacity = -1) { byte_buffer_pool(int capacity = -1) {
log = NULL;
pool = new buffer_pool<byte_buffer_t>(capacity); pool = new buffer_pool<byte_buffer_t>(capacity);
} }
~byte_buffer_pool() { ~byte_buffer_pool() {
@ -192,13 +194,20 @@ public:
byte_buffer_t* allocate(const char *debug_name = NULL, bool blocking = false) { byte_buffer_t* allocate(const char *debug_name = NULL, bool blocking = false) {
return pool->allocate(debug_name, blocking); return pool->allocate(debug_name, blocking);
} }
void set_log(srslte::log *log) {
this->log = log;
}
void deallocate(byte_buffer_t *b) { void deallocate(byte_buffer_t *b) {
if(!b) { if(!b) {
return; return;
} }
b->reset(); b->reset();
if (!pool->deallocate(b)) { if (!pool->deallocate(b)) {
printf("Error deallocating PDU: Addr=0x%lx not found in pool\n", (uint64_t) b); if (log) {
log->error("Deallocating PDU: Addr=0x%lx, name=%s not found in pool\n", (uint64_t) b, b->debug_name);
} else {
printf("Error deallocating PDU: Addr=0x%lx, name=%s not found in pool\n", (uint64_t) b, b->debug_name);
}
} }
b = NULL; b = NULL;
} }
@ -206,6 +215,7 @@ public:
pool->print_all_buffers(); pool->print_all_buffers();
} }
private: private:
srslte::log *log;
buffer_pool<byte_buffer_t> *pool; buffer_pool<byte_buffer_t> *pool;
}; };

@ -201,6 +201,7 @@ private:
srslte::log_filter rrc_log; srslte::log_filter rrc_log;
srslte::log_filter gtpu_log; srslte::log_filter gtpu_log;
srslte::log_filter s1ap_log; srslte::log_filter s1ap_log;
srslte::log_filter pool_log;
srslte::byte_buffer_pool *pool; srslte::byte_buffer_pool *pool;

@ -99,6 +99,10 @@ bool enb::init(all_args_t *args_)
gtpu_log.init("GTPU", logger); gtpu_log.init("GTPU", logger);
s1ap_log.init("S1AP", logger); s1ap_log.init("S1AP", logger);
pool_log.init("POOL", logger);
pool_log.set_level(srslte::LOG_LEVEL_ERROR);
pool->set_log(&pool_log);
// Init logs // Init logs
rf_log.set_level(srslte::LOG_LEVEL_INFO); rf_log.set_level(srslte::LOG_LEVEL_INFO);
for (int i=0;i<args->expert.phy.nof_phy_threads;i++) { for (int i=0;i<args->expert.phy.nof_phy_threads;i++) {

@ -115,6 +115,7 @@ private:
srslte::log_filter nas_log; srslte::log_filter nas_log;
srslte::log_filter gw_log; srslte::log_filter gw_log;
srslte::log_filter usim_log; srslte::log_filter usim_log;
srslte::log_filter pool_log;
all_args_t *args; all_args_t *args;
bool started; bool started;

@ -89,6 +89,10 @@ bool ue::init(all_args_t *args_) {
gw_log.init("GW ", logger); gw_log.init("GW ", logger);
usim_log.init("USIM", logger); usim_log.init("USIM", logger);
pool_log.init("POOL", logger);
pool_log.set_level(srslte::LOG_LEVEL_ERROR);
byte_buffer_pool::get_instance()->set_log(&pool_log);
// Init logs // Init logs
rf_log.set_level(srslte::LOG_LEVEL_INFO); rf_log.set_level(srslte::LOG_LEVEL_INFO);
rf_log.info("Starting UE\n"); rf_log.info("Starting UE\n");

Loading…
Cancel
Save