log_ptr: fix issue if accessing log_ptr that was reset already

during deinit of the UE/eNB it could happen that the log_ptr
was already set to null but the stack thread was still accessing
it through log_h->info()

i've moved the old macro into a new header and used as as much
as possible. there are still places in the code where similar
macros are used but we would need to change the variable name
to replace them
master
Andre Puschmann 5 years ago
parent ed646de7f1
commit 62e4bd9469

@ -0,0 +1,67 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_LOG_HELPER_H
#define SRSLTE_LOG_HELPER_H
/**
* @file log_helper.h
*
* Convenience macro to log formatted messages. It is checked if the log pointer is still valid before accessing it.
*/
namespace srslte {
#define Error(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->error(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Warning(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->warning(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Info(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->info(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Debug(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->debug(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Console(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->console(fmt, ##__VA_ARGS__); \
} \
} while (0)
} // namespace srslte
#endif // SRSLTE_LOG_HELPER_H

@ -19,12 +19,8 @@
* *
*/ */
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#include "srslte/common/pdu_queue.h" #include "srslte/common/pdu_queue.h"
#include "srslte/common/log_helper.h"
namespace srslte { namespace srslte {

@ -19,11 +19,6 @@
* *
*/ */
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#include <pthread.h> #include <pthread.h>
#include <srslte/interfaces/sched_interface.h> #include <srslte/interfaces/sched_interface.h>
#include <string.h> #include <string.h>
@ -32,6 +27,7 @@
#include "srsenb/hdr/stack/mac/mac.h" #include "srsenb/hdr/stack/mac/mac.h"
#include "srslte/common/log.h" #include "srslte/common/log.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/rwlock_guard.h" #include "srslte/common/rwlock_guard.h"
#include "srslte/common/time_prof.h" #include "srslte/common/time_prof.h"

@ -25,14 +25,10 @@
#include "srsenb/hdr/stack/mac/scheduler.h" #include "srsenb/hdr/stack/mac/scheduler.h"
#include "srsenb/hdr/stack/mac/scheduler_carrier.h" #include "srsenb/hdr/stack/mac/scheduler_carrier.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#include "srslte/common/pdu.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
#define Console(fmt, ...) srslte::logmap::get("MAC ")->console(fmt, ##__VA_ARGS__) #define Console(fmt, ...) srslte::logmap::get("MAC ")->console(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) srslte::logmap::get("MAC ")->error(fmt, ##__VA_ARGS__) #define Error(fmt, ...) srslte::logmap::get("MAC ")->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
namespace srsenb { namespace srsenb {

@ -21,13 +21,9 @@
#include "srsenb/hdr/stack/mac/scheduler_carrier.h" #include "srsenb/hdr/stack/mac/scheduler_carrier.h"
#include "srsenb/hdr/stack/mac/scheduler_metric.h" #include "srsenb/hdr/stack/mac/scheduler_metric.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
namespace srsenb { namespace srsenb {
/******************************************************* /*******************************************************

@ -21,14 +21,10 @@
#include "srsenb/hdr/stack/mac/scheduler_grid.h" #include "srsenb/hdr/stack/mac/scheduler_grid.h"
#include "srsenb/hdr/stack/mac/scheduler.h" #include "srsenb/hdr/stack/mac/scheduler.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#include <srslte/interfaces/sched_interface.h> #include <srslte/interfaces/sched_interface.h>
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
namespace srsenb { namespace srsenb {
const char* alloc_outcome_t::to_string() const const char* alloc_outcome_t::to_string() const

@ -22,14 +22,10 @@
#include <string.h> #include <string.h>
#include "srsenb/hdr/stack/mac/scheduler.h" #include "srsenb/hdr/stack/mac/scheduler.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/pdu.h" #include "srslte/common/pdu.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
using srslte::tti_point; using srslte::tti_point;
namespace srsenb { namespace srsenb {

@ -21,14 +21,10 @@
#include "srsenb/hdr/stack/mac/scheduler_metric.h" #include "srsenb/hdr/stack/mac/scheduler_metric.h"
#include "srsenb/hdr/stack/mac/scheduler_harq.h" #include "srsenb/hdr/stack/mac/scheduler_harq.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#include <string.h> #include <string.h>
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
namespace srsenb { namespace srsenb {
/***************************************************************** /*****************************************************************

@ -23,15 +23,11 @@
#include "srsenb/hdr/stack/mac/scheduler.h" #include "srsenb/hdr/stack/mac/scheduler.h"
#include "srsenb/hdr/stack/mac/scheduler_ue.h" #include "srsenb/hdr/stack/mac/scheduler_ue.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#include "srslte/common/pdu.h" #include "srslte/common/pdu.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
/****************************************************** /******************************************************
* UE class * * UE class *
******************************************************/ ******************************************************/

@ -25,13 +25,9 @@
#include <string.h> #include <string.h>
#include "srsenb/hdr/stack/mac/ue.h" #include "srsenb/hdr/stack/mac/ue.h"
#include "srslte/common/log_helper.h"
#include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/enb_interfaces.h"
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
namespace srsenb { namespace srsenb {
ue::ue(uint16_t rnti_, ue::ue(uint16_t rnti_,

@ -22,11 +22,6 @@
#ifndef SRSUE_UL_HARQ_H #ifndef SRSUE_UL_HARQ_H
#define SRSUE_UL_HARQ_H #define SRSUE_UL_HARQ_H
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#include "mux.h" #include "mux.h"
#include "proc_ra.h" #include "proc_ra.h"
#include "srslte/common/interfaces_common.h" #include "srslte/common/interfaces_common.h"

@ -19,13 +19,8 @@
* *
*/ */
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#include "srsue/hdr/stack/mac/proc_bsr.h" #include "srsue/hdr/stack/mac/proc_bsr.h"
#include "srsue/hdr/stack/mac/mac.h" #include "srslte/common/log_helper.h"
#include "srsue/hdr/stack/mac/mux.h" #include "srsue/hdr/stack/mac/mux.h"
namespace srsue { namespace srsue {

@ -19,20 +19,13 @@
* *
*/ */
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__) #include "srsue/hdr/stack/mac/proc_ra.h"
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__) #include "srslte/common/log_helper.h"
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__) #include "srsue/hdr/stack/mac/mux.h"
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#include <inttypes.h> // for printing uint64_t #include <inttypes.h> // for printing uint64_t
#include <signal.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "srsue/hdr/stack/mac/mac.h"
#include "srsue/hdr/stack/mac/mux.h"
#include "srsue/hdr/stack/mac/proc_ra.h"
/* Random access procedure as specified in Section 5.1 of 36.321 */ /* Random access procedure as specified in Section 5.1 of 36.321 */
namespace srsue { namespace srsue {

Loading…
Cancel
Save