Merge pull request #3157 from Carbenium/zmc-deadlock
Fix a possible deadlock on zmc shutdown and reconnectpull/3159/head
commit
2742485a61
|
@ -9,7 +9,7 @@ AnalysisThread::AnalysisThread(std::shared_ptr<Monitor> monitor) :
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalysisThread::~AnalysisThread() {
|
AnalysisThread::~AnalysisThread() {
|
||||||
terminate_ = true;
|
Stop();
|
||||||
if (thread_.joinable())
|
if (thread_.joinable())
|
||||||
thread_.join();
|
thread_.join();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ class AnalysisThread {
|
||||||
AnalysisThread(AnalysisThread &rhs) = delete;
|
AnalysisThread(AnalysisThread &rhs) = delete;
|
||||||
AnalysisThread(AnalysisThread &&rhs) = delete;
|
AnalysisThread(AnalysisThread &&rhs) = delete;
|
||||||
|
|
||||||
|
void Stop() { terminate_ = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
|
|
|
@ -384,8 +384,8 @@ int main(int argc, char *argv[]) {
|
||||||
} // end if zm_reload
|
} // end if zm_reload
|
||||||
} // end while ! zm_terminate and connected
|
} // end while ! zm_terminate and connected
|
||||||
|
|
||||||
// Killoff the analysis threads. Don't need them spinning while we try to reconnect
|
for (std::unique_ptr<AnalysisThread> &analysis_thread: analysis_threads)
|
||||||
analysis_threads.clear();
|
analysis_thread->Stop();
|
||||||
|
|
||||||
for (size_t i = 0; i < monitors.size(); i++) {
|
for (size_t i = 0; i < monitors.size(); i++) {
|
||||||
#if HAVE_RTSP_SERVER
|
#if HAVE_RTSP_SERVER
|
||||||
|
@ -408,6 +408,9 @@ int main(int argc, char *argv[]) {
|
||||||
camera->Close();
|
camera->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Killoff the analysis threads. Don't need them spinning while we try to reconnect
|
||||||
|
analysis_threads.clear();
|
||||||
|
|
||||||
#if HAVE_RTSP_SERVER
|
#if HAVE_RTSP_SERVER
|
||||||
if (rtsp_server_threads) {
|
if (rtsp_server_threads) {
|
||||||
delete[] rtsp_server_threads;
|
delete[] rtsp_server_threads;
|
||||||
|
|
Loading…
Reference in New Issue