mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
mutex fixes, server shutdown works again
This commit is contained in:
parent
d792c3ddc6
commit
671214c60e
9 changed files with 34 additions and 27 deletions
|
|
@ -32,7 +32,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
Server::Server(QObject *parent)
|
||||
: QObject(parent), nextGameId(0), nextReplayId(0)
|
||||
: QObject(parent), nextGameId(0), nextReplayId(0), clientsLock(QReadWriteLock::Recursive)
|
||||
{
|
||||
qRegisterMetaType<ServerInfo_Game>("ServerInfo_Game");
|
||||
qRegisterMetaType<ServerInfo_Room>("ServerInfo_Room");
|
||||
|
|
@ -45,17 +45,17 @@ Server::~Server()
|
|||
|
||||
void Server::prepareDestroy()
|
||||
{
|
||||
clientsLock.lockForWrite();
|
||||
while (!clients.isEmpty())
|
||||
clients.first()->prepareDestroy();
|
||||
clientsLock.unlock();
|
||||
|
||||
roomsLock.lockForWrite();
|
||||
QMapIterator<int, Server_Room *> roomIterator(rooms);
|
||||
while (roomIterator.hasNext())
|
||||
delete roomIterator.next().value();
|
||||
rooms.clear();
|
||||
roomsLock.unlock();
|
||||
|
||||
clientsLock.lockForWrite();
|
||||
while (!clients.isEmpty())
|
||||
delete clients.takeFirst();
|
||||
clientsLock.unlock();
|
||||
}
|
||||
|
||||
AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString &name, const QString &password, QString &reasonStr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue