diff --git a/backends/libpurple/main.cpp b/backends/libpurple/main.cpp index a0b7c8f0..f7122453 100644 --- a/backends/libpurple/main.cpp +++ b/backends/libpurple/main.cpp @@ -183,7 +183,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin { // Default avatar char* contents; gsize length; - gboolean ret; + gboolean ret = false; if (!CONFIG_STRING(config, "backend.avatars_directory").empty()) { std::string f = CONFIG_STRING(config, "backend.avatars_directory") + "/" + legacyName; ret = g_file_get_contents (f.c_str(), &contents, &length, NULL); diff --git a/include/transport/networkpluginserver.h b/include/transport/networkpluginserver.h index 7428eb6f..6c2ca240 100644 --- a/include/transport/networkpluginserver.h +++ b/include/transport/networkpluginserver.h @@ -50,6 +50,7 @@ class NetworkPluginServer { unsigned long res; unsigned long init_res; unsigned long shared; + bool acceptUsers; }; NetworkPluginServer(Component *component, Config *config, UserManager *userManager); diff --git a/spectrum/src/sample.cfg b/spectrum/src/sample.cfg index 159f0d77..68531bcb 100644 --- a/spectrum/src/sample.cfg +++ b/spectrum/src/sample.cfg @@ -10,7 +10,7 @@ admin_username=admin admin_password=test #cert= #patch to PKCS#12 certificate #cert_password= #password to that certificate if any -users_per_backend=10 +users_per_backend=2 backend=../../backends/libpurple/spectrum_libpurple_backend #backend=../../backends/libircclient-qt/spectrum_libircclient-qt_backend #protocol=prpl-jabber diff --git a/src/networkpluginserver.cpp b/src/networkpluginserver.cpp index 8f0e56fa..d39d6b99 100644 --- a/src/networkpluginserver.cpp +++ b/src/networkpluginserver.cpp @@ -182,6 +182,7 @@ void NetworkPluginServer::handleNewClientConnection(boost::shared_ptrres = 0; client->init_res = 0; client->shared = 0; + client->acceptUsers = true; LOG4CXX_INFO(logger, "New backend " << client << " connected. Current backend count=" << (m_clients.size() + 1)); @@ -190,7 +191,7 @@ void NetworkPluginServer::handleNewClientConnection(boost::shared_ptrstart(); } - m_clients.push_back(client); + m_clients.push_front(client); c->onDisconnected.connect(boost::bind(&NetworkPluginServer::handleSessionFinished, this, client)); c->onDataRead.connect(boost::bind(&NetworkPluginServer::handleDataRead, this, client, _1)); @@ -912,8 +913,11 @@ NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient() { bool spawnNew = false; for (std::list::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) { // This backend is free. - if ((*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection) { + if ((*it)->acceptUsers && (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection) { c = *it; + if (c->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) { + c->acceptUsers = false; + } break; } }