server crash fixes
This commit is contained in:
parent
4f97db62d7
commit
c65f327e71
7 changed files with 20 additions and 6 deletions
|
@ -7,8 +7,11 @@ if (NOT WITHOUT_CLIENT)
|
||||||
add_subdirectory(cockatrice)
|
add_subdirectory(cockatrice)
|
||||||
add_subdirectory(oracle)
|
add_subdirectory(oracle)
|
||||||
endif(NOT WITHOUT_CLIENT)
|
endif(NOT WITHOUT_CLIENT)
|
||||||
|
if (WITH_TESTCLIENT)
|
||||||
|
add_subdirectory(testclient)
|
||||||
|
endif(WITH_TESTCLIENT)
|
||||||
|
|
||||||
FILE(GLOB sounds "${CMAKE_CURRENT_SOURCE_DIR}/sounds/*.raw")
|
FILE(GLOB sounds "${CMAKE_CURRENT_SOURCE_DIR}/sounds/*.raw")
|
||||||
INSTALL(FILES ${sounds} DESTINATION share/cockatrice/sounds)
|
INSTALL(FILES ${sounds} DESTINATION share/cockatrice/sounds)
|
||||||
FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/zonebg/*.*")
|
FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/zonebg/*.*")
|
||||||
INSTALL(FILES ${zonebg} DESTINATION share/cockatrice/zonebg)
|
INSTALL(FILES ${zonebg} DESTINATION share/cockatrice/zonebg)
|
||||||
|
|
|
@ -140,7 +140,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
||||||
}
|
}
|
||||||
|
|
||||||
users.insert(name, session);
|
users.insert(name, session);
|
||||||
qDebug() << "Server::loginUser: name=" << name;
|
qDebug() << "Server::loginUser:" << session << "name=" << name;
|
||||||
|
|
||||||
data.set_session_id(databaseInterface->startSession(name, session->getAddress()));
|
data.set_session_id(databaseInterface->startSession(name, session->getAddress()));
|
||||||
databaseInterface->unlockSessionTables();
|
databaseInterface->unlockSessionTables();
|
||||||
|
@ -228,7 +228,7 @@ void Server::removeClient(Server_ProtocolHandler *client)
|
||||||
qDebug() << "closed session id:" << sessionId;
|
qDebug() << "closed session id:" << sessionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "Server::removeClient:" << clients.size() << "clients; " << users.size() << "users left";
|
qDebug() << "Server::removeClient: removed" << (void *) client << ";" << clients.size() << "clients; " << users.size() << "users left";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::externalUserJoined(const ServerInfo_User &userInfo)
|
void Server::externalUserJoined(const ServerInfo_User &userInfo)
|
||||||
|
|
|
@ -277,6 +277,10 @@ Response::ResponseCode Server_ProtocolHandler::processAdminCommandContainer(cons
|
||||||
|
|
||||||
void Server_ProtocolHandler::processCommandContainer(const CommandContainer &cont)
|
void Server_ProtocolHandler::processCommandContainer(const CommandContainer &cont)
|
||||||
{
|
{
|
||||||
|
// Command processing must be disabled after prepareDestroy() has been called.
|
||||||
|
if (deleted)
|
||||||
|
return;
|
||||||
|
|
||||||
lastDataReceived = timeRunning;
|
lastDataReceived = timeRunning;
|
||||||
|
|
||||||
ResponseContainer responseContainer(cont.has_cmd_id() ? cont.cmd_id() : -1);
|
ResponseContainer responseContainer(cont.has_cmd_id() ? cont.cmd_id() : -1);
|
||||||
|
|
|
@ -26,8 +26,7 @@ ServerInfo_User_Container::~ServerInfo_User_Container()
|
||||||
|
|
||||||
void ServerInfo_User_Container::setUserInfo(const ServerInfo_User &_userInfo)
|
void ServerInfo_User_Container::setUserInfo(const ServerInfo_User &_userInfo)
|
||||||
{
|
{
|
||||||
userInfo = new ServerInfo_User;
|
userInfo = new ServerInfo_User(_userInfo);
|
||||||
userInfo->CopyFrom(_userInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_User &ServerInfo_User_Container::copyUserInfo(ServerInfo_User &result, bool complete, bool internalInfo, bool sessionInfo) const
|
ServerInfo_User &ServerInfo_User_Container::copyUserInfo(ServerInfo_User &result, bool complete, bool internalInfo, bool sessionInfo) const
|
||||||
|
|
|
@ -151,6 +151,8 @@ int main(int argc, char *argv[])
|
||||||
sigemptyset(&segv.sa_mask);
|
sigemptyset(&segv.sa_mask);
|
||||||
sigaction(SIGSEGV, &segv, 0);
|
sigaction(SIGSEGV, &segv, 0);
|
||||||
sigaction(SIGABRT, &segv, 0);
|
sigaction(SIGABRT, &segv, 0);
|
||||||
|
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
rng = new RNG_SFMT;
|
rng = new RNG_SFMT;
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,7 @@ bool Servatrice::initServer()
|
||||||
|
|
||||||
const int numberPools = settings->value("server/number_pools", 1).toInt();
|
const int numberPools = settings->value("server/number_pools", 1).toInt();
|
||||||
gameServer = new Servatrice_GameServer(this, numberPools, servatriceDatabaseInterface->getDatabase(), this);
|
gameServer = new Servatrice_GameServer(this, numberPools, servatriceDatabaseInterface->getDatabase(), this);
|
||||||
|
gameServer->setMaxPendingConnections(1000);
|
||||||
const int gamePort = settings->value("server/port", 4747).toInt();
|
const int gamePort = settings->value("server/port", 4747).toInt();
|
||||||
qDebug() << "Starting server on port" << gamePort;
|
qDebug() << "Starting server on port" << gamePort;
|
||||||
if (gameServer->listen(QHostAddress::Any, gamePort))
|
if (gameServer->listen(QHostAddress::Any, gamePort))
|
||||||
|
|
|
@ -87,6 +87,10 @@ ServerSocketInterface::~ServerSocketInterface()
|
||||||
|
|
||||||
void ServerSocketInterface::initConnection(int socketDescriptor)
|
void ServerSocketInterface::initConnection(int socketDescriptor)
|
||||||
{
|
{
|
||||||
|
// Add this object to the server's list of connections before it can receive socket events.
|
||||||
|
// Otherwise, in case a of a socket error, it could be removed from the list before it is added.
|
||||||
|
server->addClient(this);
|
||||||
|
|
||||||
socket->setSocketDescriptor(socketDescriptor);
|
socket->setSocketDescriptor(socketDescriptor);
|
||||||
logger->logMessage(QString("Incoming connection: %1").arg(socket->peerAddress().toString()), this);
|
logger->logMessage(QString("Incoming connection: %1").arg(socket->peerAddress().toString()), this);
|
||||||
initSessionDeprecated();
|
initSessionDeprecated();
|
||||||
|
@ -123,7 +127,6 @@ bool ServerSocketInterface::initSession()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
server->addClient(this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,6 +719,7 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
||||||
query.bindValue(":visible_reason", QString::fromStdString(cmd.visible_reason()));
|
query.bindValue(":visible_reason", QString::fromStdString(cmd.visible_reason()));
|
||||||
sqlInterface->execSqlQuery(query);
|
sqlInterface->execSqlQuery(query);
|
||||||
|
|
||||||
|
servatrice->clientsLock.lockForRead();
|
||||||
QList<ServerSocketInterface *> userList = servatrice->getUsersWithAddressAsList(QHostAddress(address));
|
QList<ServerSocketInterface *> userList = servatrice->getUsersWithAddressAsList(QHostAddress(address));
|
||||||
ServerSocketInterface *user = static_cast<ServerSocketInterface *>(server->getUsers().value(userName));
|
ServerSocketInterface *user = static_cast<ServerSocketInterface *>(server->getUsers().value(userName));
|
||||||
if (user && !userList.contains(user))
|
if (user && !userList.contains(user))
|
||||||
|
@ -734,6 +738,7 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
||||||
QMetaObject::invokeMethod(userList[i], "prepareDestroy", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(userList[i], "prepareDestroy", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
servatrice->clientsLock.unlock();
|
||||||
|
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue