From 3cbb365c6156772de60fd008baac3633287de225 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sat, 15 Feb 2014 23:15:27 +0100 Subject: [PATCH] Don't let a websocket login kick a normal login. --- src/net/common/serverlobbythread.cpp | 11 +++++++++-- src/net/common/sessiondata.cpp | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 22d2b1a7..96da31a1 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -1685,8 +1685,15 @@ ServerLobbyThread::EstablishSession(boost::shared_ptr session) unsigned previousPlayerId = GetPlayerId(session->GetPlayerData()->GetName()); if (previousPlayerId != 0 && previousPlayerId != session->GetPlayerData()->GetUniqueId()) { #ifdef POKERTH_OFFICIAL_SERVER - // If so, and this is a login server, disconnect the already connected player. - InternalRemovePlayer(previousPlayerId, ERR_NET_PLAYER_NAME_IN_USE); + // If this is a login server with a websocket connection, decline connection. + if (session->GetWebData()) { + SessionError(session, ERR_NET_PLAYER_NAME_IN_USE); + return; + } + else { + // If this is not a websocket connection, disconnect the already connected player. + InternalRemovePlayer(previousPlayerId, ERR_NET_PLAYER_NAME_IN_USE); + } #else // If this is a server without password protection, close this new session and return. SessionError(session, ERR_NET_PLAYER_NAME_IN_USE); diff --git a/src/net/common/sessiondata.cpp b/src/net/common/sessiondata.cpp index 372300bb..fd30cc44 100644 --- a/src/net/common/sessiondata.cpp +++ b/src/net/common/sessiondata.cpp @@ -390,6 +390,7 @@ SessionData::GetPlayerData() string SessionData::GetRemoteIPAddressFromSocket() const { + boost::mutex::scoped_lock lock(m_dataMutex); string ipAddress; if (m_socket) { boost::system::error_code errCode;