windows/server: Fix crash when disconnecting sockets
This commit is contained in:
@@ -194,6 +194,7 @@ void datapath::windows::server::_watcher()
|
|||||||
|
|
||||||
// Verify existing connections.
|
// Verify existing connections.
|
||||||
{
|
{
|
||||||
|
std::list<HANDLE> to_kill;
|
||||||
std::unique_lock<std::mutex> ul(this->lock);
|
std::unique_lock<std::mutex> ul(this->lock);
|
||||||
for (auto itr = this->active_sockets.begin(); itr != this->active_sockets.end(); itr++) {
|
for (auto itr = this->active_sockets.begin(); itr != this->active_sockets.end(); itr++) {
|
||||||
if (itr->second.expired()) {
|
if (itr->second.expired()) {
|
||||||
@@ -204,7 +205,7 @@ void datapath::windows::server::_watcher()
|
|||||||
} else {
|
} else {
|
||||||
DisconnectNamedPipe(itr->first);
|
DisconnectNamedPipe(itr->first);
|
||||||
CloseHandle(itr->first);
|
CloseHandle(itr->first);
|
||||||
this->sockets.remove(itr->first);
|
to_kill.push_back(itr->first);
|
||||||
}
|
}
|
||||||
this->active_sockets.erase(itr);
|
this->active_sockets.erase(itr);
|
||||||
continue;
|
continue;
|
||||||
@@ -218,12 +219,15 @@ void datapath::windows::server::_watcher()
|
|||||||
} else {
|
} else {
|
||||||
DisconnectNamedPipe(itr->first);
|
DisconnectNamedPipe(itr->first);
|
||||||
CloseHandle(itr->first);
|
CloseHandle(itr->first);
|
||||||
this->sockets.remove(itr->first);
|
to_kill.push_back(itr->first);
|
||||||
}
|
}
|
||||||
this->active_sockets.erase(itr);
|
this->active_sockets.erase(itr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto hnd : to_kill) {
|
||||||
|
this->active_sockets.erase(hnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ovmap.size() == 0) {
|
if (ovmap.size() == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user