Changeset - 95a492462291
[Not reviewed]
0 2 0
HanzZ - 13 years ago 2012-07-28 06:04:10
hanzz.k@gmail.com
Give backend some time to start before spawning new oen
2 files changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
include/transport/networkpluginserver.h
Show inline comments
 
@@ -152,6 +152,7 @@ class NetworkPluginServer {
 
		FileTransferManager *m_ftManager;
 
		std::vector<std::string> m_crashedBackends;
 
		AdminInterface *m_adminInterface;
 
		bool m_startingBackend;
 
};
 

	
 
}
src/networkpluginserver.cpp
Show inline comments
 
@@ -229,6 +229,7 @@ NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, U
 
	m_component = component;
 
	m_isNextLongRun = false;
 
	m_adminInterface = NULL;
 
	m_startingBackend = false;
 
	m_component->m_factory = new NetworkFactory(this);
 
	m_userManager->onUserCreated.connect(boost::bind(&NetworkPluginServer::handleUserCreated, this, _1));
 
	m_userManager->onUserDestroyed.connect(boost::bind(&NetworkPluginServer::handleUserDestroyed, this, _1));
 
@@ -325,6 +326,8 @@ void NetworkPluginServer::handleNewClientConnection(boost::shared_ptr<Swift::Con
 
	client->acceptUsers = !m_isNextLongRun;
 
	client->longRun = m_isNextLongRun;
 

	
 
	m_startingBackend = false;
 

	
 
	LOG4CXX_INFO(logger, "New" + (client->longRun ? std::string(" long-running") : "") +  " backend " << client << " connected. Current backend count=" << (m_clients.size() + 1));
 

	
 
	m_clients.push_front(client);
 
@@ -930,6 +933,9 @@ void NetworkPluginServer::pingTimeout() {
 
		}
 
	}
 

	
 
	// We have to remove startingBackend flag otherwise 1 broken backend start could
 
	// block the backend.
 
	m_startingBackend = false;
 

	
 
	// check ping responses
 
	std::vector<Backend *> toRemove;
 
@@ -1472,8 +1478,9 @@ NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient(bool acceptUser
 
	}
 

	
 
	// there's no free backend, so spawn one.
 
	if (c == NULL) {
 
	if (c == NULL && !m_startingBackend) {
 
		m_isNextLongRun = longRun;
 
		m_startingBackend = true;
 
		exec_(CONFIG_STRING(m_config, "service.backend"), CONFIG_STRING(m_config, "service.backend_host").c_str(), CONFIG_STRING(m_config, "service.backend_port").c_str(), m_config->getConfigFile().c_str());
 
	}
 

	
0 comments (0 inline, 0 general)