Skip to content

Commit

Permalink
Prevent duplicate stream creation with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
getroot committed Dec 17, 2024
1 parent e01f57b commit 8d71c3f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/projects/base/provider/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,18 @@ namespace pvd
}
}

std::unique_lock<std::shared_mutex> streams_lock(_streams_guard);
_streams[stream->GetId()] = stream;
streams_lock.unlock();
{
std::lock_guard<std::shared_mutex> streams_lock(_streams_guard);

// check if stream is already exist one more time
if (_streams.find(stream->GetId()) != _streams.end())
{
logtw("Stream is already exist : %s/%s(%u)", stream->GetApplicationInfo().GetVHostAppName().CStr(), stream->GetName().CStr(), stream->GetId());
return false;
}

_streams[stream->GetId()] = stream;
}

NotifyStreamCreated(stream);

Expand Down

0 comments on commit 8d71c3f

Please sign in to comment.