diff --git a/source/windows/server.cpp b/source/windows/server.cpp index a1e3264..29869c5 100644 --- a/source/windows/server.cpp +++ b/source/windows/server.cpp @@ -194,6 +194,7 @@ void datapath::windows::server::_watcher() // Verify existing connections. { + std::list to_kill; std::unique_lock ul(this->lock); for (auto itr = this->active_sockets.begin(); itr != this->active_sockets.end(); itr++) { if (itr->second.expired()) { @@ -204,7 +205,7 @@ void datapath::windows::server::_watcher() } else { DisconnectNamedPipe(itr->first); CloseHandle(itr->first); - this->sockets.remove(itr->first); + to_kill.push_back(itr->first); } this->active_sockets.erase(itr); continue; @@ -218,12 +219,15 @@ void datapath::windows::server::_watcher() } else { DisconnectNamedPipe(itr->first); CloseHandle(itr->first); - this->sockets.remove(itr->first); + to_kill.push_back(itr->first); } this->active_sockets.erase(itr); continue; } } + for (auto hnd : to_kill) { + this->active_sockets.erase(hnd); + } } if (ovmap.size() == 0) {