Fix FELIX-3672 Protect the m_attached and m_idle fields against concurrent access while iterating over them