13
0

Fix std::set< BackendPortPtr> lookup by key

The set uses a custom sort-by-name comparator.
Previously it was possible to have an inconsistent set iterator.
std::set::find() did not find a given port while std::find() did.

This fixes using std::set::find() on the PortIndex set.
This commit is contained in:
Robin Gareus 2022-05-06 00:33:44 +02:00
parent 668cb1ca3b
commit ce95c9fb09
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -542,7 +542,16 @@ PortEngineSharedImpl::set_port_name (PortEngine::PortHandle port_handle, const s
}
const std::string old_name = port->name();
int ret = port->set_name (newname);
/* PortIndex std::set is sorted by name, using the name as key.
* So name-changes need to update the set
*/
RCUWriter<PortIndex> index_writer (_ports);
boost::shared_ptr<PortIndex> ps = index_writer.get_copy ();
ps->erase (port);
int ret = port->set_name (newname);
ps->insert (port);
if (ret == 0) {