GH-1768: Properly cleanup existing log stream when recreated on with the same ID

This commit is contained in:
Tim Wojtulewicz 2021-12-03 13:46:22 -07:00
parent e7412e257f
commit d50dade24c
2 changed files with 11 additions and 2 deletions

View file

@ -311,8 +311,11 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
streams.push_back(nullptr);
if ( streams[idx] )
// We already know this one, delete the previous definition.
delete streams[idx];
{
// We already know this one. Clean up the old version before making
// a new one.
RemoveStream(idx);
}
// Create new stream.
streams[idx] = new Stream;
@ -334,7 +337,11 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
bool Manager::RemoveStream(EnumVal* id)
{
unsigned int idx = id->AsEnum();
return RemoveStream(idx);
}
bool Manager::RemoveStream(unsigned int idx)
{
if ( idx >= streams.size() || ! streams[idx] )
return false;