From e34840024696cfa4928ac7c08d2c840d22a9c386 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Tue, 2 Jun 2020 14:10:36 -0700 Subject: [PATCH] Improved robustness of RTSP client removal handling --- daemon/rtsp_client.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/daemon/rtsp_client.cpp b/daemon/rtsp_client.cpp index 14d3938..eb92b4a 100644 --- a/daemon/rtsp_client.cpp +++ b/daemon/rtsp_client.cpp @@ -109,9 +109,8 @@ std::pair RtspClient::process( const std::string& port, bool wait_for_updates) { RtspSource rtsp_source; + ip::tcp::iostream s; try { - ip::tcp::iostream s; - BOOST_LOG_TRIVIAL(debug) << "rtsp_client:: connecting to " << "rtsp://" << address << ":" << port << path; s.connect(address, port.length() ? port : dft_port); @@ -249,9 +248,11 @@ std::pair RtspClient::process( } if (wait_for_updates) { - auto name_domain = std::make_pair(name, domain); std::lock_guard lock(g_mutex); - g_active_clients.erase(name_domain); + auto it = g_active_clients.find(std::make_pair(name, domain)); + if (it != g_active_clients.end() && it->second == &s) { + g_active_clients.erase(it); + } } return std::make_pair(true, rtsp_source);