Fix a race condition in the enb csv metrics where set_handle was called while the metrics thread is running causing a race in the enb member variable.

Fix it by setting it during object construction.
master
faluco 3 years ago committed by Andre Puschmann
parent f3b427cbd7
commit 8d33d93c77

@ -32,11 +32,10 @@ namespace srsenb {
class metrics_csv : public srsran::metrics_listener<enb_metrics_t>
{
public:
metrics_csv(std::string filename);
metrics_csv(std::string filename, enb_metrics_interface* enb_);
~metrics_csv();
void set_metrics(const enb_metrics_t& m, const uint32_t period_usec);
void set_handle(enb_metrics_interface* enb_);
void stop();
private:

@ -632,10 +632,9 @@ int main(int argc, char* argv[])
metricshub.add_listener(&metrics_screen);
metrics_screen.set_handle(enb.get());
srsenb::metrics_csv metrics_file(args.general.metrics_csv_filename);
srsenb::metrics_csv metrics_file(args.general.metrics_csv_filename, enb.get());
if (args.general.metrics_csv_enable) {
metricshub.add_listener(&metrics_file);
metrics_file.set_handle(enb.get());
}
srsenb::metrics_json json_metrics(json_channel, enb.get());

@ -27,7 +27,8 @@ using namespace std;
namespace srsenb {
metrics_csv::metrics_csv(std::string filename) : n_reports(0), metrics_report_period(1.0), enb(NULL)
metrics_csv::metrics_csv(std::string filename, enb_metrics_interface* enb_) :
n_reports(0), metrics_report_period(1.0), enb(enb_)
{
file.open(filename.c_str(), std::ios_base::out);
}
@ -37,11 +38,6 @@ metrics_csv::~metrics_csv()
stop();
}
void metrics_csv::set_handle(enb_metrics_interface* enb_)
{
enb = enb_;
}
void metrics_csv::stop()
{
if (file.is_open()) {

@ -53,8 +53,8 @@ public:
metrics[0].stack.mac.ues[0].dl_pmi = 1.0;
metrics[0].stack.mac.ues[0].phr = 12.0;
metrics[0].phy.resize(2);
metrics[0].phy[0].dl.mcs = 28.0;
metrics[0].phy[0].ul.mcs = 20.2;
metrics[0].phy[0].dl.mcs = 28.0;
metrics[0].phy[0].ul.mcs = 20.2;
metrics[0].phy[0].ul.pucch_sinr = 14.2;
metrics[0].phy[0].ul.pusch_sinr = 14.2;
@ -96,8 +96,8 @@ public:
metrics[1].stack.mac.ues[0].dl_pmi = 1.0;
metrics[1].stack.mac.ues[0].phr = 99.1;
metrics[1].phy.resize(1);
metrics[1].phy[0].dl.mcs = 6.2;
metrics[1].phy[0].ul.mcs = 28.0;
metrics[1].phy[0].dl.mcs = 6.2;
metrics[1].phy[0].ul.mcs = 28.0;
metrics[1].phy[0].ul.pucch_sinr = 22.2;
metrics[1].phy[0].ul.pusch_sinr = 22.2;
@ -119,8 +119,8 @@ public:
metrics[2].stack.mac.ues[0].dl_pmi = 1.0;
metrics[2].stack.mac.ues[0].phr = 12.0;
metrics[2].phy.resize(1);
metrics[2].phy[0].dl.mcs = 28.0;
metrics[2].phy[0].ul.mcs = 20.2;
metrics[2].phy[0].dl.mcs = 28.0;
metrics[2].phy[0].ul.mcs = 20.2;
metrics[2].phy[0].ul.pusch_sinr = 14.2;
metrics[2].phy[0].ul.pucch_sinr = 14.2;
@ -201,8 +201,7 @@ int main(int argc, char** argv)
metrics_screen.set_handle(&enb);
// the CSV file writer
metrics_csv metrics_file(csv_file_name);
metrics_file.set_handle(&enb);
metrics_csv metrics_file(csv_file_name, &enb);
// create metrics hub and register metrics for stdout
srsran::metrics_hub<enb_metrics_t> metricshub;

Loading…
Cancel
Save