@@ -74,7 +74,8 @@ class protocol_transaction_manager
7474 unsigned transaction_id = next_transaction_id.fetch_add (1 , std::memory_order_relaxed) % N;
7575 if (not transactions[transaction_id].is_set ()) {
7676 // cancel any existing awaiter.
77- set (transaction_id, cancel_value);
77+ bool ignore = set (transaction_id, cancel_value);
78+ (void )ignore;
7879 }
7980 transactions[transaction_id].reset ();
8081 return {transaction_id, transactions[transaction_id]};
@@ -90,19 +91,26 @@ class protocol_transaction_manager
9091 // Create a new timer if it doesn't exist yet.
9192 running_timers[t.id ()] = timer_db.create_unique_timer ();
9293 }
93- running_timers[t.id ()].set (time_to_cancel,
94- [this , transaction_id = t.id ()](timer_id_t tid) { set (transaction_id, cancel_value); });
94+ running_timers[t.id ()].set (time_to_cancel, [this , transaction_id = t.id ()](timer_id_t tid) {
95+ if (not set (transaction_id, cancel_value)) {
96+ srslog::fetch_basic_logger (" ALL" ).warning (" Transaction id={} timeout but transaction is already completed" ,
97+ transaction_id);
98+ }
99+ });
95100 running_timers[t.id ()].run ();
96101 return t;
97102 }
98103
99104 // / \brief Sets the result of a managed transaction with the provided transaction_id.
100105 template <typename U>
101- void set (unsigned transaction_id, U&& u)
106+ bool __attribute__ ((warn_unused_result)) set(unsigned transaction_id, U&& u)
102107 {
108+ if (transactions[transaction_id].is_set ()) {
109+ return false ;
110+ }
103111 running_timers[transaction_id].stop ();
104- srsran_assert (not transactions[transaction_id].is_set (), " Transaction result cannot be overwritten." );
105112 transactions[transaction_id].set (std::forward<U>(u));
113+ return true ;
106114 }
107115
108116private:
0 commit comments