Skip to content

Commit 512368a

Browse files
frankistcodebot
authored andcommitted
cu-cp: avoid that cu-cp stop task runs more than once
1 parent a751a6d commit 512368a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/cu_cp/cu_cp_impl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,24 @@ void cu_cp_impl::start()
114114

115115
void cu_cp_impl::stop()
116116
{
117+
bool already_stopped = stopped.exchange(true);
118+
if (already_stopped) {
119+
return;
120+
}
121+
117122
logger.info("Stopping CU-CP...");
118123
std::promise<void> p;
119124
std::future<void> fut = p.get_future();
120125

121126
// Shut down components from within CU-CP executor.
122127
while (not cfg.cu_cp_executor->execute([this, &p]() {
128+
// Stop statistics gathering.
123129
statistics_report_timer.stop();
124130

125-
routine_mng.reset();
126-
127131
// Signal back that CU-CP is stopped.
128132
p.set_value();
129133
})) {
134+
logger.debug("Failed to dispatch CU-CP stop task. Retrying...");
130135
// Keep dispatching until the task is accepted.
131136
std::this_thread::sleep_for(std::chrono::milliseconds(100));
132137
}

lib/cu_cp/cu_cp_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class cu_cp_impl final : public cu_cp_interface, public cu_cp_impl_interface
170170
std::atomic<bool> amf_connected = {false};
171171

172172
unique_timer statistics_report_timer;
173+
174+
std::atomic<bool> stopped{false};
173175
};
174176

175177
} // namespace srs_cu_cp

0 commit comments

Comments
 (0)