diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index 8a15bac13..77ea2e66c 100644 --- a/node/Multicaster.cpp +++ b/node/Multicaster.cpp @@ -275,12 +275,10 @@ void Multicaster::clean(uint64_t now) { Mutex::Lock _l(_groups_m); for(std::map< std::pair,MulticastGroupStatus >::iterator mm(_groups.begin());mm!=_groups.end();) { - for(std::vector::iterator tx(mm->second.txQueue.begin());tx!=mm->second.txQueue.end();) { - if ((tx->expired(now))||(tx->atLimit())) { - // erase element (replace by last) - *tx = mm->second.txQueue.back(); - mm->second.txQueue.pop_back(); - } else ++tx; + for(std::list::iterator tx(mm->second.txQueue.begin());tx!=mm->second.txQueue.end();) { + if ((tx->expired(now))||(tx->atLimit())) + mm->second.txQueue.erase(tx++); + else ++tx; } unsigned long count = 0; @@ -328,18 +326,14 @@ void Multicaster::_add(uint64_t now,uint64_t nwid,const MulticastGroup &mg,Multi //TRACE("..MC %s joined multicast group %.16llx/%s via %s",member.toString().c_str(),nwid,mg.toString().c_str(),((learnedFrom) ? learnedFrom.toString().c_str() : "(direct)")); - for(std::vector::iterator tx(gs.txQueue.begin());tx!=gs.txQueue.end();) { - if (tx->atLimit()) { - // erase element (replace by last) - *tx = gs.txQueue.back(); - gs.txQueue.pop_back(); - } else { + for(std::list::iterator tx(gs.txQueue.begin());tx!=gs.txQueue.end();) { + if (tx->atLimit()) + gs.txQueue.erase(tx++); + else { tx->sendIfNew(RR,member); - if (tx->atLimit()) { - // erase element (replace by last) - *tx = gs.txQueue.back(); - gs.txQueue.pop_back(); - } else ++tx; + if (tx->atLimit()) + gs.txQueue.erase(tx++); + else ++tx; } } } diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp index 281222b84..c6c93b1ff 100644 --- a/node/Multicaster.hpp +++ b/node/Multicaster.hpp @@ -70,7 +70,7 @@ private: MulticastGroupStatus() : lastExplicitGather(0) {} uint64_t lastExplicitGather; - std::vector txQueue; // pending outbound multicasts + std::list txQueue; // pending outbound multicasts std::vector members; // members of this group };