Improved robustness of RTSP client removal handling

This commit is contained in:
Andrea Bondavalli 2020-06-02 14:10:36 -07:00
parent 267b97cbe7
commit e348400246

View File

@ -109,9 +109,8 @@ std::pair<bool, RtspSource> RtspClient::process(
const std::string& port, const std::string& port,
bool wait_for_updates) { bool wait_for_updates) {
RtspSource rtsp_source; RtspSource rtsp_source;
ip::tcp::iostream s;
try { try {
ip::tcp::iostream s;
BOOST_LOG_TRIVIAL(debug) << "rtsp_client:: connecting to " BOOST_LOG_TRIVIAL(debug) << "rtsp_client:: connecting to "
<< "rtsp://" << address << ":" << port << path; << "rtsp://" << address << ":" << port << path;
s.connect(address, port.length() ? port : dft_port); s.connect(address, port.length() ? port : dft_port);
@ -249,9 +248,11 @@ std::pair<bool, RtspSource> RtspClient::process(
} }
if (wait_for_updates) { if (wait_for_updates) {
auto name_domain = std::make_pair(name, domain);
std::lock_guard<std::mutex> lock(g_mutex); std::lock_guard<std::mutex> 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); return std::make_pair(true, rtsp_source);