diff --git a/backends/libpurple/main.cpp b/backends/libpurple/main.cpp index a0b7c8f01be574cb4319b810664a68083c420b55..f7122453156828c5e8236048eeb459ad85b8a0a5 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 7428eb6f97316773ccb3196bb2c285cbaea9af22..6c2ca240338862945e3856af217dc45d653d622a 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 159f0d772f26b1986333aff9e4fdeb0af1b41cd4..68531bcbc3de8ecd983a4ac5ae930c383d8419d3 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 8f0e56fa1869cd2f3709ad6887234052633884ee..d39d6b99fe9ee5d7ad68bb954685270bb18cda1c 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; } }