Remedy connection type query at every login (#2298)

Fix #2285
This change adds an internal counter for each tcp/web socket connection
that the server makes and queries the stored memory count at login
rather than the previous way that quired the database during each login.
Each login that quired the DB put a significant load on the server as
the user base grew.
This commit is contained in:
woogerboy21 2016-12-07 01:35:35 -05:00 committed by GitHub
parent a6f1f4c01d
commit f86b9e0be7
3 changed files with 19 additions and 4 deletions

View file

@ -1259,7 +1259,7 @@ bool TcpServerSocketInterface::initTcpSession()
bool enforceUserLimit = settingsCache->value("security/enable_max_user_limit", false).toBool();
if (enforceUserLimit) {
int userLimit = settingsCache->value("security/max_users_tcp", 500).toInt();
int playerCount = (databaseInterface->getActiveUserCount(getConnectionType()) + 1);
int playerCount = (server->getTCPUserCount() + 1);
if (playerCount > userLimit){
std::cerr << "Max Tcp Users Limit Reached, please increase the max_users_tcp setting." << std::endl;
logger->logMessage(QString("Max Tcp Users Limit Reached, please increase the max_users_tcp setting."), this);
@ -1313,7 +1313,7 @@ bool WebsocketServerSocketInterface::initWebsocketSession()
bool enforceUserLimit = settingsCache->value("security/enable_max_user_limit", false).toBool();
if (enforceUserLimit) {
int userLimit = settingsCache->value("security/max_users_websocket", 500).toInt();
int playerCount = (databaseInterface->getActiveUserCount(getConnectionType()) + 1);
int playerCount = (server->getWebSocketUserCount() + 1);
if (playerCount > userLimit){
std::cerr << "Max Websocket Users Limit Reached, please increase the max_users_websocket setting." << std::endl;
logger->logMessage(QString("Max Websocket Users Limit Reached, please increase the max_users_websocket setting."), this);