event/SocketEvent: allow Close() without socket

This commit is contained in:
Max Kellermann
2020-10-14 16:23:13 +02:00
parent 7fc04fd5cd
commit 9f013f7de4
2 changed files with 4 additions and 2 deletions

View File

@@ -75,7 +75,6 @@ public:
OneServerSocket &operator=(const OneServerSocket &other) = delete; OneServerSocket &operator=(const OneServerSocket &other) = delete;
~OneServerSocket() noexcept { ~OneServerSocket() noexcept {
if (IsDefined())
Close(); Close();
} }

View File

@@ -50,6 +50,9 @@ SocketEvent::Steal() noexcept
void void
SocketEvent::Close() noexcept SocketEvent::Close() noexcept
{ {
if (!fd.IsDefined())
return;
Steal().Close(); Steal().Close();
} }