Changeset - 6aa34a558531
[Not reviewed]
0 4 0
Jan Kaluza - 14 years ago 2011-07-25 17:49:41
hanzz.k@gmail.com
Don't use backends which were full in past and add users to latest backends instead
4 files changed with 9 insertions and 4 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -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);
include/transport/networkpluginserver.h
Show inline comments
 
@@ -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);
spectrum/src/sample.cfg
Show inline comments
 
@@ -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
src/networkpluginserver.cpp
Show inline comments
 
@@ -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;
 
		}
 
	}
0 comments (0 inline, 0 general)