replay: fix hangs on exit (#32795)
fix hang on exit old-commit-hash: 776b08d561ebdfa9bd12e92b57ab0770f4a4b4a3
This commit is contained in:
@@ -27,6 +27,13 @@ CameraServer::CameraServer(std::pair<int, int> camera_size[MAX_CAMERAS]) {
|
||||
CameraServer::~CameraServer() {
|
||||
for (auto &cam : cameras_) {
|
||||
if (cam.thread.joinable()) {
|
||||
// Clear the queue
|
||||
std::pair<FrameReader*, const Event *> item;
|
||||
while (cam.queue.try_pop(item)) {
|
||||
--publishing_;
|
||||
}
|
||||
|
||||
// Signal termination and join the thread
|
||||
cam.queue.push({});
|
||||
cam.thread.join();
|
||||
}
|
||||
|
||||
@@ -50,20 +50,20 @@ Replay::~Replay() {
|
||||
}
|
||||
|
||||
void Replay::stop() {
|
||||
if (!stream_thread_ && segments_.empty()) return;
|
||||
|
||||
rInfo("shutdown: in progress...");
|
||||
exit_ = true;
|
||||
if (stream_thread_ != nullptr) {
|
||||
exit_ = true;
|
||||
rInfo("shutdown: in progress...");
|
||||
pauseStreamThread();
|
||||
stream_cv_.notify_one();
|
||||
stream_thread_->quit();
|
||||
stream_thread_->wait();
|
||||
stream_thread_->deleteLater();
|
||||
stream_thread_ = nullptr;
|
||||
rInfo("shutdown: done");
|
||||
}
|
||||
timeline_future.waitForFinished();
|
||||
rInfo("shutdown: done");
|
||||
camera_server_.reset(nullptr);
|
||||
segments_.clear();
|
||||
}
|
||||
|
||||
bool Replay::load() {
|
||||
|
||||
Reference in New Issue
Block a user