summaryrefslogtreecommitdiff
path: root/src/network/core/tcp_http.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-05-13 11:46:51 +0200
committerGitHub <noreply@github.com>2021-05-13 11:46:51 +0200
commita403653805c6fd6022868c5f381e10107e1d2b20 (patch)
treeb44e4df40d65cf1fecdadab090badb73d78e0a6d /src/network/core/tcp_http.cpp
parent86741ad489c3ee2d519eeb071be846721b90412c (diff)
downloadopenttd-a403653805c6fd6022868c5f381e10107e1d2b20.tar.xz
Codechange: [Network] split CloseSocket and CloseConnection more clearly (#9261)
* Codechange: [Network] split CloseSocket and CloseConnection more clearly - CloseSocket now closes the actual OS socket. - CloseConnection frees up the resources to just before CloseSocket. - dtors call CloseSocket / CloseConnection where needed.
Diffstat (limited to 'src/network/core/tcp_http.cpp')
-rw-r--r--src/network/core/tcp_http.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp
index 08961e402..f11722ae3 100644
--- a/src/network/core/tcp_http.cpp
+++ b/src/network/core/tcp_http.cpp
@@ -68,17 +68,18 @@ NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(SOCKET s,
/** Free whatever needs to be freed. */
NetworkHTTPSocketHandler::~NetworkHTTPSocketHandler()
{
- this->CloseConnection();
+ this->CloseSocket();
- if (this->sock != INVALID_SOCKET) closesocket(this->sock);
- this->sock = INVALID_SOCKET;
free(this->data);
}
-NetworkRecvStatus NetworkHTTPSocketHandler::CloseConnection(bool error)
+/**
+ * Close the actual socket of the connection.
+ */
+void NetworkHTTPSocketHandler::CloseSocket()
{
- NetworkSocketHandler::CloseConnection(error);
- return NETWORK_RECV_STATUS_OKAY;
+ if (this->sock != INVALID_SOCKET) closesocket(this->sock);
+ this->sock = INVALID_SOCKET;
}
/**
@@ -313,7 +314,7 @@ int NetworkHTTPSocketHandler::Receive()
if (ret < 0) cur->callback->OnFailure();
if (ret <= 0) {
/* Then... the connection can be closed */
- cur->CloseConnection();
+ cur->CloseSocket();
iter = _http_connections.erase(iter);
delete cur;
continue;