Skip to content

Commit

Permalink
Allow immediate server deletion if there are no active connections. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
slaff authored Nov 14, 2017
1 parent 286ef0e commit 8fe3888
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sming/SmingCore/Network/TcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ TcpServer::TcpServer(TcpClientDataDelegate clientReceiveDataHandler)

TcpServer::~TcpServer()
{
debugf("Server is destroyed.");
}

TcpConnection* TcpServer::createClient(tcp_pcb *clientTcp)
Expand Down Expand Up @@ -258,6 +259,11 @@ void TcpServer::shutdown()
tcp = NULL;
}

if(!connections.count()) {
delete this;
return;
}

for(int i=0; i < connections.count(); i++) {
TcpConnection* connection = connections[i];
if(connection == NULL) {
Expand All @@ -278,7 +284,6 @@ void TcpServer::onClientDestroy(TcpConnection& connection)
}

if(connections.count() == 0) {
debugf("Server is destroyed.");
delete this;
}
}

0 comments on commit 8fe3888

Please sign in to comment.