Merge branch 'experimental' of git://cockatrice.git.sourceforge.net/gitroot/cockatrice/cockatrice
This commit is contained in:
commit
6a77e765a7
4 changed files with 12 additions and 6 deletions
|
@ -406,6 +406,7 @@ ResponseCode Server_ProtocolHandler::cmdJoinRoom(Command_JoinRoom *cmd, CommandC
|
|||
if (!r)
|
||||
return RespNameNotFound;
|
||||
|
||||
QMutexLocker serverLocker(&server->serverMutex);
|
||||
QMutexLocker roomLocker(&r->roomMutex);
|
||||
r->addClient(this);
|
||||
rooms.insert(r->getId(), r);
|
||||
|
|
|
@ -129,8 +129,8 @@ int main(int argc, char *argv[])
|
|||
if (testRandom)
|
||||
testRNG();
|
||||
|
||||
Servatrice server(settings);
|
||||
QObject::connect(&server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection);
|
||||
Servatrice *server = new Servatrice(settings);
|
||||
QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection);
|
||||
|
||||
std::cerr << "-------------------------" << std::endl;
|
||||
std::cerr << "Server initialized." << std::endl;
|
||||
|
@ -142,6 +142,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
delete rng;
|
||||
delete settings;
|
||||
delete loggerThread;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent)
|
|||
}
|
||||
|
||||
bool threaded = settings->value("server/threaded", false).toInt();
|
||||
tcpServer = new Servatrice_TcpServer(this, threaded);
|
||||
tcpServer = new Servatrice_TcpServer(this, threaded, this);
|
||||
int port = settings->value("server/port", 4747).toInt();
|
||||
qDebug() << "Starting server on port" << port;
|
||||
if (tcpServer->listen(QHostAddress::Any, port))
|
||||
|
@ -364,17 +364,20 @@ void Servatrice::updateLoginMessage()
|
|||
|
||||
void Servatrice::statusUpdate()
|
||||
{
|
||||
QMutexLocker locker(&dbMutex);
|
||||
const int uc = getUsersCount(); // for correct mutex locking order
|
||||
const int gc = getGamesCount();
|
||||
|
||||
uptime += statusUpdateClock->interval() / 1000;
|
||||
|
||||
QMutexLocker locker(&dbMutex);
|
||||
checkSql();
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("insert into " + dbPrefix + "_uptime (id_server, timest, uptime, users_count, games_count) values(:id, NOW(), :uptime, :users_count, :games_count)");
|
||||
query.bindValue(":id", serverId);
|
||||
query.bindValue(":uptime", uptime);
|
||||
query.bindValue(":users_count", getUsersCount());
|
||||
query.bindValue(":games_count", getGamesCount());
|
||||
query.bindValue(":users_count", uc);
|
||||
query.bindValue(":games_count", gc);
|
||||
execSqlQuery(query);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ ServerSocketInterface::~ServerSocketInterface()
|
|||
delete xmlReader;
|
||||
delete socket;
|
||||
socket = 0;
|
||||
delete topLevelItem;
|
||||
}
|
||||
|
||||
void ServerSocketInterface::processProtocolItem(ProtocolItem *item)
|
||||
|
|
Loading…
Reference in a new issue