destroyAllChannels() swap out channels list

avoid possible modifications while iterating.
This commit is contained in:
Michael Davidsaver
2018-02-13 17:51:20 -08:00
parent 8e88f534bb
commit a266777d82

View File

@@ -1586,11 +1586,11 @@ void BlockingServerTCPTransportCodec::destroyAllChannels() {
_socketName.c_str(), _channels.size());
}
_channels_t::iterator it(_channels.begin());
for(; it!=_channels.end(); it++)
it->second->destroy();
_channels_t temp;
temp.swap(_channels);
_channels.clear();
for(_channels_t::iterator it(temp.begin()), end(temp.end()); it!=end; ++it)
it->second->destroy();
}
void BlockingServerTCPTransportCodec::internalClose(bool force) {