diff --git a/lib/include/srslte/common/mac_pcap.h b/lib/include/srslte/common/mac_pcap.h index c556f8250..1d84476f4 100644 --- a/lib/include/srslte/common/mac_pcap.h +++ b/lib/include/srslte/common/mac_pcap.h @@ -28,7 +28,6 @@ public: private: void write_pdu(srslte::mac_pcap_base::pcap_pdu_t& pdu); - void run_thread() final; FILE* pcap_file = nullptr; uint32_t dlt = 0; // The DLT used for the PCAP file diff --git a/lib/include/srslte/common/mac_pcap_base.h b/lib/include/srslte/common/mac_pcap_base.h index fd2d35aae..67fd706b0 100644 --- a/lib/include/srslte/common/mac_pcap_base.h +++ b/lib/include/srslte/common/mac_pcap_base.h @@ -91,7 +91,7 @@ protected: } pcap_pdu_t; virtual void write_pdu(pcap_pdu_t& pdu) = 0; - virtual void run_thread() = 0; + void run_thread() final; std::mutex mutex; srslog::basic_logger& logger; diff --git a/lib/include/srslte/common/mac_pcap_net.h b/lib/include/srslte/common/mac_pcap_net.h index 1f38e7407..a470d373c 100644 --- a/lib/include/srslte/common/mac_pcap_net.h +++ b/lib/include/srslte/common/mac_pcap_net.h @@ -35,7 +35,6 @@ private: void write_pdu(srslte::mac_pcap_base::pcap_pdu_t& pdu); void write_mac_lte_pdu_to_net(srslte::mac_pcap_base::pcap_pdu_t& pdu); void write_mac_nr_pdu_to_net(srslte::mac_pcap_base::pcap_pdu_t& pdu); - void run_thread() final; srslte::socket_handler_t socket; struct sockaddr_in client_addr; diff --git a/lib/src/common/mac_pcap.cc b/lib/src/common/mac_pcap.cc index 3ad0e75f8..650542ab9 100644 --- a/lib/src/common/mac_pcap.cc +++ b/lib/src/common/mac_pcap.cc @@ -47,25 +47,6 @@ uint32_t mac_pcap::open(std::string filename_, uint32_t ue_id_) return SRSLTE_SUCCESS; } -void mac_pcap::run_thread() -{ - // blocking write until stopped - while (running) { - pcap_pdu_t pdu = queue.wait_pop(); - { - std::lock_guard lock(mutex); - write_pdu(pdu); - } - } - - // write remainder of queue - std::lock_guard lock(mutex); - pcap_pdu_t pdu = {}; - while (queue.try_pop(&pdu)) { - write_pdu(pdu); - } -} - uint32_t mac_pcap::close() { { diff --git a/lib/src/common/mac_pcap_base.cc b/lib/src/common/mac_pcap_base.cc index 5b8016006..979cfaab8 100644 --- a/lib/src/common/mac_pcap_base.cc +++ b/lib/src/common/mac_pcap_base.cc @@ -33,6 +33,25 @@ void mac_pcap_base::set_ue_id(uint16_t ue_id_) ue_id = ue_id_; } +void mac_pcap_base::run_thread() +{ + // blocking write until stopped + while (running) { + pcap_pdu_t pdu = queue.wait_pop(); + { + std::lock_guard lock(mutex); + write_pdu(pdu); + } + } + + // write remainder of queue + std::lock_guard lock(mutex); + pcap_pdu_t pdu = {}; + while (queue.try_pop(&pdu)) { + write_pdu(pdu); + } +} + // Function called from PHY worker context, locking not needed as PDU queue is thread-safe void mac_pcap_base::pack_and_queue(uint8_t* payload, uint32_t payload_len, diff --git a/lib/src/common/mac_pcap_net.cc b/lib/src/common/mac_pcap_net.cc index 027cfa844..45bc488c7 100644 --- a/lib/src/common/mac_pcap_net.cc +++ b/lib/src/common/mac_pcap_net.cc @@ -79,25 +79,6 @@ uint32_t mac_pcap_net::close() return SRSLTE_SUCCESS; } -void mac_pcap_net::run_thread() -{ - // blocking write until stopped - while (running) { - pcap_pdu_t pdu = queue.wait_pop(); - { - std::lock_guard lock(mutex); - write_pdu(pdu); - } - } - - // write remainder of queue - std::lock_guard lock(mutex); - pcap_pdu_t pdu = {}; - while (queue.try_pop(&pdu)) { - write_pdu(pdu); - } -} - void mac_pcap_net::write_pdu(pcap_pdu_t& pdu) { if (pdu.pdu != nullptr && socket.is_init()) {