Don't use backends which were full in past and add users to latest backends instead
This commit is contained in:
parent
e2d8481aaa
commit
6aa34a5585
4 changed files with 9 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -182,6 +182,7 @@ void NetworkPluginServer::handleNewClientConnection(boost::shared_ptr<Swift::Con
|
|||
client->res = 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_ptr<Swift::Con
|
|||
m_component->start();
|
||||
}
|
||||
|
||||
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<Backend *>::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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue