diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/core/core.h | 5 | ||||
-rw-r--r-- | src/network/core/tcp.cpp | 3 | ||||
-rw-r--r-- | src/network/core/tcp_content.cpp | 6 | ||||
-rw-r--r-- | src/network/core/tcp_content.h | 8 | ||||
-rw-r--r-- | src/network/core/udp.h | 2 | ||||
-rw-r--r-- | src/network/network_content.cpp | 4 | ||||
-rw-r--r-- | src/network/network_content.h | 2 |
7 files changed, 18 insertions, 12 deletions
diff --git a/src/network/core/core.h b/src/network/core/core.h index 37948ad52..a16ed9f23 100644 --- a/src/network/core/core.h +++ b/src/network/core/core.h @@ -46,10 +46,7 @@ public: NetworkSocketHandler() { this->has_quit = false; } /** Close the socket when destructing the socket handler */ - virtual ~NetworkSocketHandler() { this->Close(); } - - /** Really close the socket */ - virtual void Close() {} + virtual ~NetworkSocketHandler() {} /** * Close the current connection; for TCP this will be mostly equivalent diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index 3bba291c7..5c436edf0 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -29,7 +29,8 @@ NetworkTCPSocketHandler::NetworkTCPSocketHandler(SOCKET s) : NetworkTCPSocketHandler::~NetworkTCPSocketHandler() { - this->CloseConnection(); + /* Virtual functions get called statically in destructors, so make it explicit to remove any confusion. */ + this->NetworkTCPSocketHandler::CloseConnection(); if (this->sock != INVALID_SOCKET) closesocket(this->sock); this->sock = INVALID_SOCKET; diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp index 0371b7621..3abf1c29c 100644 --- a/src/network/core/tcp_content.cpp +++ b/src/network/core/tcp_content.cpp @@ -137,9 +137,11 @@ const char *ContentInfo::GetTextfile(TextfileType type) const return ::GetTextfile(type, GetContentInfoSubDir(this->type), tmp); } -void NetworkContentSocketHandler::Close() +/** + * Close the actual socket. + */ +void NetworkContentSocketHandler::CloseSocket() { - CloseConnection(); if (this->sock == INVALID_SOCKET) return; closesocket(this->sock); diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h index 52cae1e0e..b1bde4817 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -21,7 +21,7 @@ /** Base socket handler for all Content TCP sockets */ class NetworkContentSocketHandler : public NetworkTCPSocketHandler { protected: - void Close() override; + void CloseSocket(); bool ReceiveInvalidPacket(PacketContentType type); @@ -124,7 +124,11 @@ public: } /** On destructing of this class, the socket needs to be closed */ - virtual ~NetworkContentSocketHandler() { this->Close(); } + virtual ~NetworkContentSocketHandler() + { + /* Virtual functions get called statically in destructors, so make it explicit to remove any confusion. */ + this->CloseSocket(); + } bool ReceivePackets(); }; diff --git a/src/network/core/udp.h b/src/network/core/udp.h index 881fb0a61..ab898eeee 100644 --- a/src/network/core/udp.h +++ b/src/network/core/udp.h @@ -190,7 +190,7 @@ public: virtual ~NetworkUDPSocketHandler() { this->Close(); } bool Listen(); - void Close() override; + void Close(); void SendPacket(Packet *p, NetworkAddress *recv, bool all = false, bool broadcast = false); void ReceivePackets(); diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index e4f368618..26d220b6a 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -784,7 +784,9 @@ void ClientNetworkContentSocketHandler::Connect() void ClientNetworkContentSocketHandler::Close() { if (this->sock == INVALID_SOCKET) return; - NetworkContentSocketHandler::Close(); + + this->CloseConnection(); + this->CloseSocket(); this->OnDisconnect(); } diff --git a/src/network/network_content.h b/src/network/network_content.h index f28821a0b..13b93417c 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -107,7 +107,7 @@ public: void Connect(); void SendReceive(); - void Close() override; + void Close(); void RequestContentList(ContentType type); void RequestContentList(uint count, const ContentID *content_ids); |