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)
|
if (!r)
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
|
|
||||||
|
QMutexLocker serverLocker(&server->serverMutex);
|
||||||
QMutexLocker roomLocker(&r->roomMutex);
|
QMutexLocker roomLocker(&r->roomMutex);
|
||||||
r->addClient(this);
|
r->addClient(this);
|
||||||
rooms.insert(r->getId(), r);
|
rooms.insert(r->getId(), r);
|
||||||
|
|
|
@ -129,8 +129,8 @@ int main(int argc, char *argv[])
|
||||||
if (testRandom)
|
if (testRandom)
|
||||||
testRNG();
|
testRNG();
|
||||||
|
|
||||||
Servatrice server(settings);
|
Servatrice *server = new Servatrice(settings);
|
||||||
QObject::connect(&server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection);
|
QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection);
|
||||||
|
|
||||||
std::cerr << "-------------------------" << std::endl;
|
std::cerr << "-------------------------" << std::endl;
|
||||||
std::cerr << "Server initialized." << std::endl;
|
std::cerr << "Server initialized." << std::endl;
|
||||||
|
@ -142,6 +142,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
delete rng;
|
delete rng;
|
||||||
delete settings;
|
delete settings;
|
||||||
|
delete loggerThread;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool threaded = settings->value("server/threaded", false).toInt();
|
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();
|
int port = settings->value("server/port", 4747).toInt();
|
||||||
qDebug() << "Starting server on port" << port;
|
qDebug() << "Starting server on port" << port;
|
||||||
if (tcpServer->listen(QHostAddress::Any, port))
|
if (tcpServer->listen(QHostAddress::Any, port))
|
||||||
|
@ -364,17 +364,20 @@ void Servatrice::updateLoginMessage()
|
||||||
|
|
||||||
void Servatrice::statusUpdate()
|
void Servatrice::statusUpdate()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&dbMutex);
|
const int uc = getUsersCount(); // for correct mutex locking order
|
||||||
|
const int gc = getGamesCount();
|
||||||
|
|
||||||
uptime += statusUpdateClock->interval() / 1000;
|
uptime += statusUpdateClock->interval() / 1000;
|
||||||
|
|
||||||
|
QMutexLocker locker(&dbMutex);
|
||||||
checkSql();
|
checkSql();
|
||||||
|
|
||||||
QSqlQuery query;
|
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.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(":id", serverId);
|
||||||
query.bindValue(":uptime", uptime);
|
query.bindValue(":uptime", uptime);
|
||||||
query.bindValue(":users_count", getUsersCount());
|
query.bindValue(":users_count", uc);
|
||||||
query.bindValue(":games_count", getGamesCount());
|
query.bindValue(":games_count", gc);
|
||||||
execSqlQuery(query);
|
execSqlQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ ServerSocketInterface::~ServerSocketInterface()
|
||||||
delete xmlReader;
|
delete xmlReader;
|
||||||
delete socket;
|
delete socket;
|
||||||
socket = 0;
|
socket = 0;
|
||||||
|
delete topLevelItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSocketInterface::processProtocolItem(ProtocolItem *item)
|
void ServerSocketInterface::processProtocolItem(ProtocolItem *item)
|
||||||
|
|
Loading…
Reference in a new issue