From 08418b17cefe5205946cd1fb61850465f8d64d3b Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 30 Sep 2019 12:48:35 +0200 Subject: [PATCH] fix concurrency issue in TTCN3 PHY --- srsue/test/ttcn3/hdr/lte_ttcn3_phy.h | 2 ++ srsue/test/ttcn3/src/lte_ttcn3_phy.cc | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h index d9f91377d..117bbf7a3 100644 --- a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h +++ b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h @@ -138,6 +138,8 @@ private: int sr_tx_tti = -1; bool sr_pending = false; + std::mutex mutex; + uint32_t ra_trans_cnt = 0; stack_interface_phy_lte* stack = nullptr; diff --git a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc index a0f63e52c..76aad5c13 100644 --- a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc +++ b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc @@ -31,7 +31,6 @@ lte_ttcn3_phy::lte_ttcn3_phy(srslte::logger* logger_) : logger(logger_) {} lte_ttcn3_phy::~lte_ttcn3_phy() {} int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, syssim_interface_phy* syssim_) - { stack = stack_; syssim = syssim_; @@ -69,6 +68,7 @@ void lte_ttcn3_phy::get_metrics(phy_metrics_t* m) {} // The interface for the SS void lte_ttcn3_phy::set_cell_map(const cell_list_t& cells_) { + std::lock_guard lock(mutex); cells = cells_; } @@ -140,6 +140,8 @@ void lte_ttcn3_phy::set_config_mbsfn_mcch(asn1::rrc::mcch_msg_s* mcch){}; /* Cell search and selection procedures */ phy_interface_rrc_lte::cell_search_ret_t lte_ttcn3_phy::cell_search(phy_cell_t* found_cell) { + std::lock_guard lock(mutex); + log.info("Running cell search in PHY\n"); cell_search_ret_t ret = {}; @@ -259,6 +261,8 @@ void lte_ttcn3_phy::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], u // Called from the SYSSIM to configure the current TTI void lte_ttcn3_phy::set_current_tti(uint32_t tti) { + std::lock_guard lock(mutex); + current_tti = tti; run_tti(); } @@ -282,6 +286,7 @@ float lte_ttcn3_phy::get_pathloss_db() } // Only provides a new UL grant, Tx is then triggered +// Calling function hold mutex void lte_ttcn3_phy::new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t ul_mac_grant) { mac_interface_phy_lte::tb_action_ul_t ul_action = {}; @@ -298,6 +303,8 @@ void lte_ttcn3_phy::new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t ul_mac_gr // Provides DL grant, copy data into DL action and pass up to MAC void lte_ttcn3_phy::new_tb(const srsue::mac_interface_phy_lte::mac_grant_dl_t dl_grant, const uint8_t* data) { + std::lock_guard lock(mutex); + if (data == nullptr) { log.error("Invalid data buffer passed\n"); return; @@ -345,6 +352,7 @@ void lte_ttcn3_phy::radio_failure() log.debug("%s not implemented.\n", __FUNCTION__); } +// Calling function set_tti() is holding mutex void lte_ttcn3_phy::run_tti() { // send report for each cell