Changeset - ad49c6f5676f
[Not reviewed]
0 4 0
HanzZ - 14 years ago 2011-07-29 22:54:28
hanzz.k@gmail.com
added collect_backend admininterface command + collecting one backend every 2 hours
4 files changed with 9 insertions and 4 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -217,7 +217,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 

	
 
			purple_account_set_password(account, password.c_str());
 
			purple_account_set_enabled(account, "spectrum", TRUE);
 
			purple_account_set_bool(account, "custom_smileys", FALSE));
 
			purple_account_set_bool(account, "custom_smileys", FALSE);
 
			
 
			const PurpleStatusType *status_type = purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_AVAILABLE);
 
			if (status_type != NULL) {
include/transport/networkpluginserver.h
Show inline comments
 
@@ -66,6 +66,8 @@ class NetworkPluginServer {
 
			return m_clients;
 
		}
 

	
 
		void collectBackend();
 

	
 
		void handleMessageReceived(NetworkConversation *conv, boost::shared_ptr<Swift::Message> &message);
 

	
 
	private:
 
@@ -104,7 +106,6 @@ class NetworkPluginServer {
 
		void send(boost::shared_ptr<Swift::Connection> &, const std::string &data);
 

	
 
		void pingTimeout();
 
		void collectBackend();
 
		void sendPing(Backend *c);
 
		Backend *getFreeClient();
 

	
src/admininterface.cpp
Show inline comments
 
@@ -237,6 +237,9 @@ void AdminInterface::handleMessageReceived(Swift::Message::ref message) {
 

	
 
		message->setBody(lst);
 
	}
 
	else if (message->getBody() == "collect_backend") {
 
		m_server->collectBackend();
 
	}
 
	else if (message->getBody().find("help") == 0) {
 
		std::string help;
 
		help += "General:\n";
src/networkpluginserver.cpp
Show inline comments
 
@@ -146,7 +146,7 @@ NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, U
 
	m_pingTimer->onTick.connect(boost::bind(&NetworkPluginServer::pingTimeout, this));
 
	m_pingTimer->start();
 

	
 
	m_collectTimer = component->getNetworkFactories()->getTimerFactory()->createTimer(3600000);
 
	m_collectTimer = component->getNetworkFactories()->getTimerFactory()->createTimer(2*3600000);
 
	m_collectTimer->onTick.connect(boost::bind(&NetworkPluginServer::collectBackend, this));
 
	m_collectTimer->start();
 

	
 
@@ -601,6 +601,7 @@ void NetworkPluginServer::collectBackend() {
 
	}
 

	
 
	if (backend) {
 
		m_collectTimer->start();
 
		LOG4CXX_INFO(logger, "Backend " << backend << "is set to die");
 
		backend->acceptUsers = false;
 
	}
 
@@ -962,7 +963,7 @@ void NetworkPluginServer::sendPing(Backend *c) {
 

	
 
NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient() {
 
	NetworkPluginServer::Backend *c = NULL;
 
	bool spawnNew = false;
 
// 	bool spawnNew = false;
 
	for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
 
		// This backend is free.
 
		if ((*it)->acceptUsers && (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection) {
0 comments (0 inline, 0 general)