1919#include " srsran/f1u/du/f1u_rx_pdu_handler.h"
2020#include " srsran/f1u/du/f1u_tx_pdu_notifier.h"
2121#include " srsran/ran/up_transport_layer_info.h"
22+ #include < mutex>
2223
2324namespace srsran {
2425class f1u_dl_local_adapter : public srs_cu_up ::f1u_tx_pdu_notifier
@@ -31,12 +32,14 @@ class f1u_dl_local_adapter : public srs_cu_up::f1u_tx_pdu_notifier
3132
3233 void attach_du_handler (srs_du::f1u_rx_pdu_handler& handler_, const up_transport_layer_info& dl_tnl_info_)
3334 {
35+ std::unique_lock<std::mutex> lock (handler_mutex);
3436 handler = &handler_;
3537 dl_tnl_info.emplace (dl_tnl_info_);
3638 }
3739
3840 void detach_du_handler (const up_transport_layer_info& dl_tnl_info_)
3941 {
42+ std::unique_lock<std::mutex> lock (handler_mutex);
4043 if (dl_tnl_info == dl_tnl_info_) {
4144 handler = nullptr ;
4245 dl_tnl_info.reset ();
@@ -49,6 +52,7 @@ class f1u_dl_local_adapter : public srs_cu_up::f1u_tx_pdu_notifier
4952
5053 void on_new_pdu (nru_dl_message msg) override
5154 {
55+ std::unique_lock<std::mutex> lock (handler_mutex);
5256 if (handler == nullptr ) {
5357 logger.log_info (" Cannot handle NR-U DL message. DU bearer does not exist." );
5458 return ;
@@ -58,8 +62,11 @@ class f1u_dl_local_adapter : public srs_cu_up::f1u_tx_pdu_notifier
5862 };
5963
6064private:
61- srs_cu_up::f1u_bearer_logger logger;
62- srs_du::f1u_rx_pdu_handler* handler = nullptr ;
65+ srs_cu_up::f1u_bearer_logger logger;
66+
67+ srs_du::f1u_rx_pdu_handler* handler = nullptr ;
68+ std::mutex handler_mutex;
69+
6370 optional<up_transport_layer_info> dl_tnl_info;
6471};
6572
@@ -81,11 +88,22 @@ class f1u_ul_local_adapter : public srs_du::f1u_tx_pdu_notifier
8188 logger(" DU-F1-U" , {ue_index, drb_id, dl_tnl_info})
8289 {
8390 }
84- void attach_cu_handler (srs_cu_up::f1u_rx_pdu_handler& handler_) { handler = &handler_; }
85- void detach_cu_handler () { handler = nullptr ; }
91+
92+ void attach_cu_handler (srs_cu_up::f1u_rx_pdu_handler& handler_)
93+ {
94+ std::unique_lock<std::mutex> lock (handler_mutex);
95+ handler = &handler_;
96+ }
97+
98+ void detach_cu_handler ()
99+ {
100+ std::unique_lock<std::mutex> lock (handler_mutex);
101+ handler = nullptr ;
102+ }
86103
87104 void on_new_pdu (nru_ul_message msg) override
88105 {
106+ std::unique_lock<std::mutex> lock (handler_mutex);
89107 if (handler == nullptr ) {
90108 logger.log_info (" Cannot handle NR-U UL message. CU-UP bearer does not exist." );
91109 return ;
@@ -94,8 +112,10 @@ class f1u_ul_local_adapter : public srs_du::f1u_tx_pdu_notifier
94112 };
95113
96114private:
115+ srs_du::f1u_bearer_logger logger;
116+
97117 srs_cu_up::f1u_rx_pdu_handler* handler = nullptr ;
98- srs_du::f1u_bearer_logger logger ;
118+ std::mutex handler_mutex ;
99119};
100120
101121} // namespace srsran
0 commit comments