Skip to content

Commit

Permalink
Changed socket error from an exception to only log + disconnect client
Browse files Browse the repository at this point in the history
  • Loading branch information
frozenblit committed Oct 11, 2019
1 parent 0d8b056 commit 9ed6524
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pol-core/pol/network/client.h
Expand Up @@ -293,13 +293,13 @@ inline void Client::forceDisconnect()
// Checks whether the client is disconnected, and not only marked for disconnection
inline bool Client::isReallyConnected() const
{
return !( this->disconnect );
return !this->disconnect && this->csocket != INVALID_SOCKET;
}

// Checks for both planned and executed disconnections
inline bool Client::isConnected() const
{
return !( this->preDisconnect || this->disconnect );
return !this->preDisconnect && this->isReallyConnected();
}

inline bool Client::isActive() const
Expand Down
12 changes: 7 additions & 5 deletions pol-core/pol/network/clientthread.cpp
Expand Up @@ -92,11 +92,13 @@ bool client_io_thread( Network::Client* client, bool login )
checkpoint = 1;
if ( !clientpoller.prepare( client->have_queued_data() ) )
{
POLLOG.Format( "Client#{}: ERROR - couldn't poll socket={}\n" )
<< client->instance_ << client->csocket;

if ( client->csocket != INVALID_SOCKET )
client->forceDisconnect();

throw std::runtime_error(
"couldn't prepare for polling client socket - limit is reached or invalid socket" );
break;
}
checkpoint = 2;

Expand Down Expand Up @@ -266,9 +268,9 @@ bool client_io_thread( Network::Client* client, bool login )
CLIENT_CHECKPOINT( 9 );
PolLock lck;
client->unregister();
INFO_PRINT << "Client disconnected from " << client->ipaddrAsString()
<< " (" << networkManager.clients.size() << "/"
<< networkManager.getNumberOfLoginClients() << " connections)\n";
INFO_PRINT << "Client disconnected from " << client->ipaddrAsString() << " ("
<< networkManager.clients.size() << "/" << networkManager.getNumberOfLoginClients()
<< " connections)\n";

CoreSetSysTrayToolTip( Clib::tostring( networkManager.clients.size() ) + " clients connected",
ToolTipPrioritySystem );
Expand Down

0 comments on commit 9ed6524

Please sign in to comment.