Use mutex to prevent joining of players when start selection
This commit is contained in:
parent
2d86adce3c
commit
db68756fd6
@ -463,6 +463,7 @@ void ServerLobby::signalRaceStartToClients()
|
||||
*/
|
||||
void ServerLobby::startSelection(const Event *event)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_connection_mutex);
|
||||
if (NetworkConfig::get()->isWAN())
|
||||
{
|
||||
assert(m_server_registered);
|
||||
@ -663,6 +664,7 @@ void ServerLobby::clientDisconnected(Event* event)
|
||||
*/
|
||||
void ServerLobby::connectionRequested(Event* event)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_connection_mutex);
|
||||
STKPeer* peer = event->getPeer();
|
||||
const NetworkString &data = event->data();
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "utils/synchronised.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
class ServerLobby : public LobbyProtocol
|
||||
@ -66,6 +67,10 @@ private:
|
||||
/** Timeout counter for showing the result screen. */
|
||||
float m_timeout;
|
||||
|
||||
/** Lock this mutex whenever a client is connect / disconnect or
|
||||
* starting race. */
|
||||
std::mutex m_connection_mutex;
|
||||
|
||||
// connection management
|
||||
void clientDisconnected(Event* event);
|
||||
void connectionRequested(Event* event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user